summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorotto <otto@openbsd.org>2020-05-08 11:14:35 +0000
committerotto <otto@openbsd.org>2020-05-08 11:14:35 +0000
commit48050c6b8f7e57bcce06662d2c7bbeedc6c58560 (patch)
treed7a36db0ac104b8e6b8a625110d25d60772fcb6d
parentld.so(1) also ignores LD_LIBRARY_PATH an friends for set-group-ID executables (diff)
downloadwireguard-openbsd-48050c6b8f7e57bcce06662d2c7bbeedc6c58560.tar.xz
wireguard-openbsd-48050c6b8f7e57bcce06662d2c7bbeedc6c58560.zip
Make sure cmsgbufs are properly aligned by using the idiom from the
CMSG_DATA man page. Avoids SIGBUS on landisk; ok kettenis@ jca@
-rw-r--r--usr.bin/dig/lib/isc/unix/socket.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/usr.bin/dig/lib/isc/unix/socket.c b/usr.bin/dig/lib/isc/unix/socket.c
index 0a2ea57e29e..dd803bc27a8 100644
--- a/usr.bin/dig/lib/isc/unix/socket.c
+++ b/usr.bin/dig/lib/isc/unix/socket.c
@@ -834,9 +834,14 @@ doio_recv(isc_socket_t *sock, isc_socketevent_t *dev) {
struct msghdr msghdr;
isc_buffer_t *buffer;
int recv_errno;
- char cmsgbuf[RECVCMSGBUFLEN] = {0};
+ union {
+ struct msghdr msghdr;
+ char m[RECVCMSGBUFLEN];
+ } cmsgbuf;
+
+ memset(&cmsgbuf, 0, sizeof(cmsgbuf));
- build_msghdr_recv(sock, cmsgbuf, dev, &msghdr, iov, &read_count);
+ build_msghdr_recv(sock, cmsgbuf.m, dev, &msghdr, iov, &read_count);
cc = recvmsg(sock->fd, &msghdr, 0);
recv_errno = errno;
@@ -989,9 +994,14 @@ doio_send(isc_socket_t *sock, isc_socketevent_t *dev) {
char addrbuf[ISC_SOCKADDR_FORMATSIZE];
int attempts = 0;
int send_errno;
- char cmsgbuf[SENDCMSGBUFLEN] = {0};
-
- build_msghdr_send(sock, cmsgbuf, dev, &msghdr, iov, &write_count);
+ union {
+ struct msghdr msghdr;
+ char m[SENDCMSGBUFLEN];
+ } cmsgbuf;
+
+ memset(&cmsgbuf, 0, sizeof(cmsgbuf));
+
+ build_msghdr_send(sock, cmsgbuf.m, dev, &msghdr, iov, &write_count);
resend:
cc = sendmsg(sock->fd, &msghdr, 0);