Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Add missing terminated NUL in sockaddr_un's length

This was potentially observable when using non-abstract AF_UNIX datagram sockets to processes written in another programming language.
7 changes: 6 additions & 1 deletion Modules/socketmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1683,6 +1683,8 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args,
"AF_UNIX path too long");
goto unix_out;
}

*len_ret = path.len + offsetof(struct sockaddr_un, sun_path);
}
else
#endif /* linux */
Expand All @@ -1694,10 +1696,13 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args,
goto unix_out;
}
addr->sun_path[path.len] = 0;

/* including the tailing NUL */
*len_ret = path.len + offsetof(struct sockaddr_un, sun_path) + 1;
}
addr->sun_family = s->sock_family;
memcpy(addr->sun_path, path.buf, path.len);
*len_ret = path.len + offsetof(struct sockaddr_un, sun_path);

retval = 1;
unix_out:
PyBuffer_Release(&path);
Expand Down