mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Align buffer for cmsg
`char control[CMSG_SPACE(sizeof(*out_cmsg_value)) + 1];` is not aligned as cmsghdr. Accessing its member may lead to a -fsanitize=alignment failure. Align `control` to struct cmsghdr to fix the issue. PiperOrigin-RevId: 555951052
This commit is contained in:
@@ -258,7 +258,7 @@ void RecvCmsg(int sock, int cmsg_level, int cmsg_type, char buf[],
|
||||
iov.iov_len = *buf_size,
|
||||
};
|
||||
// Add an extra byte to confirm we only read what we expected.
|
||||
char control[CMSG_SPACE(sizeof(*out_cmsg_value)) + 1];
|
||||
alignas(struct cmsghdr) char control[CMSG_SPACE(sizeof(*out_cmsg_value)) + 1];
|
||||
msghdr msg = {
|
||||
.msg_iov = &iov,
|
||||
.msg_iovlen = 1,
|
||||
|
||||
Reference in New Issue
Block a user