]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
socket-util: tweak commenting in socket_address_get_path()
authorLennart Poettering <lennart@poettering.net>
Mon, 15 Oct 2018 16:27:33 +0000 (18:27 +0200)
committerLennart Poettering <lennart@poettering.net>
Mon, 15 Oct 2018 17:40:51 +0000 (19:40 +0200)
Let's make clear explicitly that there's always a NUL byte following the
path, and how.

src/basic/socket-util.c

index 6b3c6592a5252ef2530597e4b99dbee468093c6f..c55f67964ee28f136360a2facd6ffec0b96d1643 100644 (file)
@@ -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;
 }