Skip to content

Commit

Permalink
Pass the correct sockaddr len to connect()
Browse files Browse the repository at this point in the history
According to man 7 unix, the length must include the terminating NUL
byte, and the assumption that sun_family and sun_path are the only
fields in struct sockaddr_un is not portable.
  • Loading branch information
DemiMarie committed Apr 11, 2024
1 parent 4f278aa commit 7957eea
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion daemon/qrexec-client.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ static int connect_unix_socket(const char *domname)
if (res >= (int)sizeof(remote.sun_path))
errx(1, "%s/qrexec.%s is too long for AF_UNIX socket path",
socket_dir, domname);
len = strlen(remote.sun_path) + sizeof(remote.sun_family);
len = (size_t)res + 1 + offsetof(struct sockaddr_un, sun_path);
if (connect(s, (struct sockaddr *) &remote, len) == -1) {
PERROR("connect");
exit(1);
Expand Down

0 comments on commit 7957eea

Please sign in to comment.