diff options
author | Lennart Poettering <lennart@poettering.net> | 2018-10-15 18:27:33 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2018-10-15 19:40:51 +0200 |
commit | 48e6a2dc8467204f75eef1b29a245ff39e0592ce (patch) | |
tree | d0bc5b08dd3193360b156c1e45e8a99991d0665c /src/basic/socket-util.c | |
parent | 69995bffb7f2fb589e2191523859afd896c02220 (diff) | |
download | systemd-48e6a2dc8467204f75eef1b29a245ff39e0592ce.tar.gz |
socket-util: tweak commenting in socket_address_get_path()
Let's make clear explicitly that there's always a NUL byte following the
path, and how.
Diffstat (limited to 'src/basic/socket-util.c')
-rw-r--r-- | src/basic/socket-util.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/basic/socket-util.c b/src/basic/socket-util.c index 6b3c6592a5..c55f67964e 100644 --- a/src/basic/socket-util.c +++ b/src/basic/socket-util.c @@ -489,6 +489,10 @@ const char* socket_address_get_path(const SocketAddress *a) { if (a->sockaddr.un.sun_path[0] == 0) return NULL; + /* Note that this is only safe because we know that there's an extra NUL byte after the sockaddr_un + * structure. On Linux AF_UNIX file system socket addresses don't have to be NUL terminated if they take up the + * full sun_path space. */ + assert_cc(sizeof(union sockaddr_union) >= sizeof(struct sockaddr_un)+1); return a->sockaddr.un.sun_path; } |