summaryrefslogtreecommitdiff
path: root/usr.sbin/unbound/util
diff options
context:
space:
mode:
authorJeremie Courreges-Anglas <jca@cvs.openbsd.org>2020-05-08 20:13:48 +0000
committerJeremie Courreges-Anglas <jca@cvs.openbsd.org>2020-05-08 20:13:48 +0000
commit14e8adb89202989eda8f23e793314d6c6f227bf2 (patch)
tree2c20c31b8e5df4246bd935ea5afe2001cfce7afd /usr.sbin/unbound/util
parent141906127e294a4a30eb7c46b82b9703c9634089 (diff)
Use a union to ensure cmsg buffer is properly aligned
Fix synced from unwind/libunbound. unwind(8) crash on landisk (strict alignement arch) reported by otto@, original diff ok deraadt@ otto@
Diffstat (limited to 'usr.sbin/unbound/util')
-rw-r--r--usr.sbin/unbound/util/netevent.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/usr.sbin/unbound/util/netevent.c b/usr.sbin/unbound/util/netevent.c
index 9fe5da2d45a..dbc9f4cd8f3 100644
--- a/usr.sbin/unbound/util/netevent.c
+++ b/usr.sbin/unbound/util/netevent.c
@@ -447,7 +447,10 @@ comm_point_send_udp_msg_if(struct comm_point *c, sldns_buffer* packet,
ssize_t sent;
struct msghdr msg;
struct iovec iov[1];
- char control[256];
+ union {
+ struct cmsghdr hdr;
+ char buf[256];
+ } control;
#ifndef S_SPLINT_S
struct cmsghdr *cmsg;
#endif /* S_SPLINT_S */
@@ -465,7 +468,7 @@ comm_point_send_udp_msg_if(struct comm_point *c, sldns_buffer* packet,
iov[0].iov_len = sldns_buffer_remaining(packet);
msg.msg_iov = iov;
msg.msg_iovlen = 1;
- msg.msg_control = control;
+ msg.msg_control = control.buf;
#ifndef S_SPLINT_S
msg.msg_controllen = sizeof(control);
#endif /* S_SPLINT_S */
@@ -584,7 +587,10 @@ comm_point_udp_ancil_callback(int fd, short event, void* arg)
struct msghdr msg;
struct iovec iov[1];
ssize_t rcv;
- char ancil[256];
+ union {
+ struct cmsghdr hdr;
+ char buf[256];
+ } ancil;
int i;
#ifndef S_SPLINT_S
struct cmsghdr* cmsg;
@@ -608,7 +614,7 @@ comm_point_udp_ancil_callback(int fd, short event, void* arg)
iov[0].iov_len = sldns_buffer_remaining(rep.c->buffer);
msg.msg_iov = iov;
msg.msg_iovlen = 1;
- msg.msg_control = ancil;
+ msg.msg_control = ancil.buf;
#ifndef S_SPLINT_S
msg.msg_controllen = sizeof(ancil);
#endif /* S_SPLINT_S */