From 1e4efc60db210cd9d2c4b0add03ee860b66cd0da Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Wed, 13 Sep 2023 11:32:37 -0400 Subject: [PATCH] MT#57977 initialise cmsg buffer Older glibc uses a strange (and seemingly broken) approach to verifying the cmsg structures by inspecting the *next* cmsg header and using its length to see if there is enough space in the buffer. Since we're constructing the cmsg list, at this point there is no next cmsg yet, therefore causing spurious failures of CMSG_NXTHDR. Work around this by initialising the entire buffer first. See https://github.com/bminor/glibc/commit/9c443ac4559a47ed99859bd80d14dc4b6dd220a1 closes #1720 Change-Id: I00ce9bc5686ab0c1612aff51f1b3e75d8cbd8a69 --- lib/socket.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/socket.h b/lib/socket.h index df9be3e38..48ed49a66 100644 --- a/lib/socket.h +++ b/lib/socket.h @@ -180,10 +180,9 @@ INLINE int is_addr_unspecified(const sockaddr_t *a) { INLINE ssize_t socket_sendiov(socket_t *s, const struct iovec *v, unsigned int len, const endpoint_t *dst, const sockaddr_t *src) { - struct msghdr mh; - char ctrl[64]; + struct msghdr mh = {0}; + char ctrl[64] = {0}; - ZERO(mh); mh.msg_iov = (void *) v; mh.msg_iovlen = len;