summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2020-04-21 09:55:50 +0100
committerRoy Marples <roy@marples.name>2020-04-21 09:59:40 +0100
commit713c37d6b40baf02a90cbc6479529442cb35ec55 (patch)
tree2be9b4af1cb3e59f2aa66867d0dc319740ca9e7c /src
parent1dc1fce7ae7b4c106a8eb631ed92ab1ed8e86bbc (diff)
downloaddhcpcd-713c37d6b40baf02a90cbc6479529442cb35ec55.tar.xz
align CMSG buffer
Diffstat (limited to 'src')
-rw-r--r--src/dhcp.c9
-rw-r--r--src/dhcp6.c7
-rw-r--r--src/ipv6nd.c8
3 files changed, 17 insertions, 7 deletions
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;