summaryrefslogtreecommitdiffstats
path: root/src/journal/journald-stream.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2020-04-24 23:54:25 +0200
committerLennart Poettering <lennart@poettering.net>2020-05-07 14:39:44 +0200
commitfb29cdbef21f1d66e2ebe600601897b6578d3959 (patch)
treeb0e0b17b4259ea901f706f8e365ed3b3817f12dd /src/journal/journald-stream.c
parenttree-wide: remove redundant assignments (diff)
downloadsystemd-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-stream.c')
-rw-r--r--src/journal/journald-stream.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/journal/journald-stream.c b/src/journal/journald-stream.c
index 202ac3cda2..4dadbd62be 100644
--- a/src/journal/journald-stream.c
+++ b/src/journal/journald-stream.c
@@ -489,7 +489,7 @@ static int stdout_stream_scan(StdoutStream *s, bool force_flush) {
}
static int stdout_stream_process(sd_event_source *es, int fd, uint32_t revents, void *userdata) {
- uint8_t buf[CMSG_SPACE(sizeof(struct ucred))];
+ CMSG_BUFFER_TYPE(CMSG_SPACE(sizeof(struct ucred))) control;
StdoutStream *s = userdata;
struct ucred *ucred;
struct iovec iovec;
@@ -500,8 +500,8 @@ static int stdout_stream_process(sd_event_source *es, int fd, uint32_t revents,
struct msghdr msghdr = {
.msg_iov = &iovec,
.msg_iovlen = 1,
- .msg_control = buf,
- .msg_controllen = sizeof(buf),
+ .msg_control = &control,
+ .msg_controllen = sizeof(control),
};
assert(s);