From: Roy Marples Date: Tue, 21 Apr 2020 08:55:50 +0000 (+0100) Subject: align CMSG buffer X-Git-Tag: v9.0.2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e14045cae2a4b66995a87bbc40c4516a00d4c087;p=thirdparty%2Fdhcpcd.git align CMSG buffer --- diff --git a/src/dhcp.c b/src/dhcp.c index 3fd72f85..bcb4ee9b 100644 --- a/src/dhcp.c +++ b/src/dhcp.c @@ -3609,15 +3609,18 @@ dhcp_readudp(struct dhcpcd_ctx *ctx, struct interface *ifp) .iov_base = buf, .iov_len = sizeof(buf), }; + union { + struct cmsghdr hdr; #ifdef IP_RECVIF - unsigned char ctl[CMSG_SPACE(sizeof(struct sockaddr_dl))] = { 0 }; + uint8_t buf[CMSG_SPACE(sizeof(struct sockaddr_dl))]; #else - unsigned char ctl[CMSG_SPACE(sizeof(struct in_pktinfo))] = { 0 }; + uint8_t buf[CMSG_SPACE(sizeof(struct in_pktinfo))]; #endif + } cmsgbuf = { .buf = { 0 } }; struct msghdr msg = { .msg_name = &from, .msg_namelen = sizeof(from), .msg_iov = &iov, .msg_iovlen = 1, - .msg_control = ctl, .msg_controllen = sizeof(ctl), + .msg_control = buf, .msg_controllen = sizeof(cmsgbuf.buf), }; int s; ssize_t bytes; diff --git a/src/dhcp6.c b/src/dhcp6.c index 3103e7e0..db3c7e2e 100644 --- a/src/dhcp6.c +++ b/src/dhcp6.c @@ -3642,11 +3642,14 @@ dhcp6_recv(struct dhcpcd_ctx *ctx, struct ipv6_addr *ia) .iov_base = buf, .iov_len = sizeof(buf), }; - unsigned char ctl[CMSG_SPACE(sizeof(struct in6_pktinfo))] = { 0 }; + union { + struct cmsghdr hdr; + uint8_t buf[CMSG_SPACE(sizeof(struct in6_pktinfo))]; + } cmsgbuf = { .buf = { 0 } }; struct msghdr msg = { .msg_name = &from, .msg_namelen = sizeof(from), .msg_iov = &iov, .msg_iovlen = 1, - .msg_control = ctl, .msg_controllen = sizeof(ctl), + .msg_control = cmsgbuf.buf, .msg_controllen = sizeof(cmsgbuf.buf), }; int s; ssize_t bytes; diff --git a/src/ipv6nd.c b/src/ipv6nd.c index 1b048db9..f1f83d5f 100644 --- a/src/ipv6nd.c +++ b/src/ipv6nd.c @@ -1909,11 +1909,15 @@ ipv6nd_handledata(void *arg) .iov_base = buf, .iov_len = sizeof(buf), }; - unsigned char ctl[CMSG_SPACE(sizeof(struct in6_pktinfo)) + CMSG_SPACE(sizeof(int))] = { 0 }; + union { + struct cmsghdr hdr; + uint8_t buf[CMSG_SPACE(sizeof(struct in6_pktinfo)) + + CMSG_SPACE(sizeof(int))]; + } cmsgbuf = { .buf = { 0 } }; struct msghdr msg = { .msg_name = &from, .msg_namelen = sizeof(from), .msg_iov = &iov, .msg_iovlen = 1, - .msg_control = ctl, .msg_controllen = sizeof(ctl), + .msg_control = cmsgbuf.buf, .msg_controllen = sizeof(cmsgbuf.buf), }; ssize_t len;