diff options
author | Lennart Poettering <lennart@poettering.net> | 2020-04-24 23:54:25 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2020-05-07 14:39:44 +0200 |
commit | fb29cdbef21f1d66e2ebe600601897b6578d3959 (patch) | |
tree | b0e0b17b4259ea901f706f8e365ed3b3817f12dd /src/journal/journald-syslog.c | |
parent | tree-wide: remove redundant assignments (diff) | |
download | systemd-fb29cdbef21f1d66e2ebe600601897b6578d3959.tar.xz systemd-fb29cdbef21f1d66e2ebe600601897b6578d3959.zip |
tree-wide: make sure our control buffers are properly aligned
We always need to make them unions with a "struct cmsghdr" in them, so
that things properly aligned. Otherwise we might end up at an unaligned
address and the counting goes all wrong, possibly making the kernel
refuse our buffers.
Also, let's make sure we initialize the control buffers to zero when
sending, but leave them uninitialized when reading.
Both the alignment and the initialization thing is mentioned in the
cmsg(3) man page.
Diffstat (limited to 'src/journal/journald-syslog.c')
-rw-r--r-- | src/journal/journald-syslog.c | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/src/journal/journald-syslog.c b/src/journal/journald-syslog.c index 1325b56385..46013c3878 100644 --- a/src/journal/journald-syslog.c +++ b/src/journal/journald-syslog.c @@ -39,10 +39,7 @@ static void forward_syslog_iovec( .msg_iovlen = n_iovec, }; struct cmsghdr *cmsg; - union { - struct cmsghdr cmsghdr; - uint8_t buf[CMSG_SPACE(sizeof(struct ucred))]; - } control; + CMSG_BUFFER_TYPE(CMSG_SPACE(sizeof(struct ucred))) control; const char *j; int r; |