]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/libsystemd/sd-bus/bus-socket.c
tree-wide: use CMSG_SPACE() (and not CMSG_LEN()) to allocate control buffers
authorLennart Poettering <lennart@poettering.net>
Fri, 24 Apr 2020 21:36:03 +0000 (23:36 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 7 May 2020 12:39:44 +0000 (14:39 +0200)
commita258f4915a2674d77e656755e5a4fa23059f778a
treea3e3d921a74c2daafb2890af3c260907b265fd95
parent6bae4b905ccf512aadb66e357a845079b8b41f53
tree-wide: use CMSG_SPACE() (and not CMSG_LEN()) to allocate control buffers

We need to use the CMSG_SPACE() macro to size the control buffers, not
CMSG_LEN(). The former is rounded up to next alignment boundary, the
latter is not. The former should be used for allocations, the latter for
encoding how much of it is actually initialized. See cmsg(3) man page
for details about this.

Given how confusing this is, I guess we don't have to be too ashamed
here, in most cases we actually did get this right.
src/libsystemd-network/sd-dhcp-client.c
src/libsystemd-network/sd-dhcp-server.c
src/libsystemd/sd-bus/bus-socket.c
src/resolve/resolved-manager.c