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/udev/udevd.c | |
parent | 0d9d333672167f7c4586c1708eee53066ce8f55d (diff) | |
download | systemd-fb29cdbef21f1d66e2ebe600601897b6578d3959.tar.gz |
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/udev/udevd.c')
-rw-r--r-- | src/udev/udevd.c | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/src/udev/udevd.c b/src/udev/udevd.c index cfda47f849..d3f9d532e1 100644 --- a/src/udev/udevd.c +++ b/src/udev/udevd.c @@ -906,10 +906,7 @@ static int on_worker(sd_event_source *s, int fd, uint32_t revents, void *userdat .iov_base = &msg, .iov_len = sizeof(msg), }; - union { - struct cmsghdr cmsghdr; - uint8_t buf[CMSG_SPACE(sizeof(struct ucred))]; - } control = {}; + CMSG_BUFFER_TYPE(CMSG_SPACE(sizeof(struct ucred))) control; struct msghdr msghdr = { .msg_iov = &iovec, .msg_iovlen = 1, |