summaryrefslogtreecommitdiff
path: root/Xtranssock.c
diff options
context:
space:
mode:
authorJames Cloos <cloos@jhcloos.com>2008-04-25 15:53:20 -0400
committerJames Cloos <cloos@jhcloos.com>2008-04-25 15:54:51 -0400
commit960902584a3ef125946beb5ebe331b54d697e9d9 (patch)
tree87994277513fb9014cf716cc06b2fda667927766 /Xtranssock.c
parent3a2a5375b8aab85697b4f2644ab99c3ccf79e658 (diff)
Fix length calculation for the path for abstract unix domain sockets
Since the struct has a fixed-lenght char[] its sizeof() contains trailing NUL octets which results in corrupt abstract sockets. Instead, take the strlen(3) of the path, plus the single NUL octet (which identifies the path as an abstract path rather than a file- system path) plus the offset from the start of the struct to the start of the char array. This fixes: https://bugs.freedesktop.org/show_bug.cgi?id=15677
Diffstat (limited to 'Xtranssock.c')
-rw-r--r--Xtranssock.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/Xtranssock.c b/Xtranssock.c
index 8f64429..9be7f5a 100644
--- a/Xtranssock.c
+++ b/Xtranssock.c
@@ -1180,7 +1180,7 @@ TRANS(SocketUNIXCreateListener) (XtransConnInfo ciptr, char *port,
if (abstract) {
sockname.sun_path[0] = '\0';
- namelen = sizeof(sockname);
+ namelen = offsetof(struct sockaddr_un, sun_path) + 1 + strlen(&sockname.sun_path[1]);
}
else
unlink (sockname.sun_path);