summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-03-02 14:44:31 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-03-02 15:47:41 +0100
commit64177e9e4e8b377b12980161d92a03923c2fa890 (patch)
treea6cbfed4ca08a8a218221ccb8c1bb44fc89c4d04
parent8ad2012d1e017939bb50a6c8ac09ebec9f08dee7 (diff)
downloadsystemd-64177e9e4e8b377b12980161d92a03923c2fa890.tar.gz
journald: fix forwarding to syslog
.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.
-rw-r--r--src/journal/journald-syslog.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/journal/journald-syslog.c b/src/journal/journald-syslog.c
index 59ce983bb9..2a5749517e 100644
--- a/src/journal/journald-syslog.c
+++ b/src/journal/journald-syslog.c
@@ -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;