]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
align CMSG buffer
authorRoy Marples <roy@marples.name>
Tue, 21 Apr 2020 08:55:50 +0000 (09:55 +0100)
committerRoy Marples <roy@marples.name>
Tue, 21 Apr 2020 08:59:40 +0000 (09:59 +0100)
src/dhcp.c
src/dhcp6.c
src/ipv6nd.c

index 3fd72f851e80d62f0de0cef3d2dbeb34319a62a5..bcb4ee9b194027331a9d10622b97bd8a0d4a88be 100644 (file)
@@ -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;
index 3103e7e034d5974bd66bd4122415668c5542bd03..db3c7e2e491440bcb278271123587d86c4e512c6 100644 (file)
@@ -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;
index 1b048db90115f007f24a749829c70fca96aab3fc..f1f83d5f7b8a19039e34102eb10c9a905cd59fda 100644 (file)
@@ -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;