chiark / gitweb /
util: never use sizeof(sa_family_t) when calculating sockaddr sizes
[elogind.git] / src / execute.c
index 755b4700fc0c02fbbe1bcb1b03459ff45998e6db..6db048c5fce1d669981de7c5dd9d314c1e0b3e95 100644 (file)
@@ -174,7 +174,7 @@ static int connect_logger_as(const ExecContext *context, ExecOutput output, cons
         sa.sa.sa_family = AF_UNIX;
         strncpy(sa.un.sun_path+1, LOGGER_SOCKET, sizeof(sa.un.sun_path)-1);
 
-        if (connect(fd, &sa.sa, sizeof(sa_family_t) + 1 + sizeof(LOGGER_SOCKET) - 1) < 0) {
+        if (connect(fd, &sa.sa, offsetof(struct sockaddr_un, sun_path) + 1 + sizeof(LOGGER_SOCKET) - 1) < 0) {
                 close_nointr_nofail(fd);
                 return -errno;
         }