]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journald: fix forwarding to syslog
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 2 Mar 2020 13:44:31 +0000 (14:44 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 2 Mar 2020 14:47:41 +0000 (15:47 +0100)
.msg_namelen was set to a bogus value before we actually stored the path in the
the structure. sockaddr_un_set_path() returns the length, so just use that.

Fixes #14799.

src/journal/journald-syslog.c

index 59ce983bb937d500f714e4e57c03ae3e4ff6ac8f..2a5749517e6ee2ab745cdbf654cf4a9567dc216f 100644 (file)
@@ -32,14 +32,11 @@ static void forward_syslog_iovec(
                 const struct ucred *ucred,
                 const struct timeval *tv) {
 
-        union sockaddr_union sa = {
-                .un.sun_family = AF_UNIX,
-        };
+        union sockaddr_union sa;
+
         struct msghdr msghdr = {
                 .msg_iov = (struct iovec *) iovec,
                 .msg_iovlen = n_iovec,
-                .msg_name = (struct sockaddr*) &sa.sa,
-                .msg_namelen = SOCKADDR_UN_LEN(sa.un),
         };
         struct cmsghdr *cmsg;
         union {
@@ -60,6 +57,9 @@ static void forward_syslog_iovec(
                 return;
         }
 
+        msghdr.msg_name = &sa.sa;
+        msghdr.msg_namelen = r;
+
         if (ucred) {
                 zero(control);
                 msghdr.msg_control = &control;