Skip to content

Commit 7957eea

Browse files
committed
Pass the correct sockaddr len to connect()
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.
1 parent 4f278aa commit 7957eea

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

daemon/qrexec-client.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ static int connect_unix_socket(const char *domname)
187187
if (res >= (int)sizeof(remote.sun_path))
188188
errx(1, "%s/qrexec.%s is too long for AF_UNIX socket path",
189189
socket_dir, domname);
190-
len = strlen(remote.sun_path) + sizeof(remote.sun_family);
190+
len = (size_t)res + 1 + offsetof(struct sockaddr_un, sun_path);
191191
if (connect(s, (struct sockaddr *) &remote, len) == -1) {
192192
PERROR("connect");
193193
exit(1);

0 commit comments

Comments
 (0)