summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2008-03-24 16:11:09 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2008-03-24 16:11:09 +0000
commit0bdf18c9edb2e6a9fa89a28e89d11e7b6785b1fd (patch)
treebd0dc86a525e38150bde9f0c3d55ad9dfeb4e6a2 /usr.sbin
parent6e48c70f167662c7aec42af9bafc316e322ef92a (diff)
msg_controllen has to be CMSG_SPACE so that the kernel can account for
each cmsg_len (ie. msg_controllen = sum of CMSG_ALIGN(cmsg_len). This works now that kernel fd passing has been fixed to accept a bit of sloppiness because of this ABI repair. lots of discussion with kettenis
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/bgpd/buffer.c6
-rw-r--r--usr.sbin/bgpd/imsg.c4
-rw-r--r--usr.sbin/bind/lib/isc/unix/privsep_fdpass.c6
-rw-r--r--usr.sbin/bind/lib/isc/unix/socket.c42
-rw-r--r--usr.sbin/ospf6d/packet.c4
-rw-r--r--usr.sbin/ospfd/packet.c4
-rw-r--r--usr.sbin/ppp/ppp/bundle.c6
-rw-r--r--usr.sbin/relayd/buffer.c6
-rw-r--r--usr.sbin/relayd/imsg.c4
-rw-r--r--usr.sbin/ripd/packet.c4
-rw-r--r--usr.sbin/route6d/route6d.c8
-rw-r--r--usr.sbin/rtadvd/rtadvd.c12
-rw-r--r--usr.sbin/rtsold/probe.c6
-rw-r--r--usr.sbin/rtsold/rtsol.c10
-rw-r--r--usr.sbin/snmpd/buffer.c6
-rw-r--r--usr.sbin/snmpd/imsg.c4
-rw-r--r--usr.sbin/syslogd/privsep_fdpass.c6
-rw-r--r--usr.sbin/tcpdump/privsep_fdpass.c6
-rw-r--r--usr.sbin/traceroute6/traceroute6.c10
19 files changed, 65 insertions, 89 deletions
diff --git a/usr.sbin/bgpd/buffer.c b/usr.sbin/bgpd/buffer.c
index 77a8fbef91a..a25818cef78 100644
--- a/usr.sbin/bgpd/buffer.c
+++ b/usr.sbin/bgpd/buffer.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: buffer.c,v 1.38 2008/03/15 16:19:00 deraadt Exp $ */
+/* $OpenBSD: buffer.c,v 1.39 2008/03/24 16:11:02 deraadt Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -178,9 +178,9 @@ msgbuf_write(struct msgbuf *msgbuf)
if (buf != NULL && buf->fd != -1) {
msg.msg_control = (caddr_t)&cmsgbuf.buf;
- msg.msg_controllen = CMSG_LEN(sizeof(int));
+ msg.msg_controllen = sizeof(cmsgbuf.buf);
cmsg = CMSG_FIRSTHDR(&msg);
- cmsg->cmsg_len = msg.msg_controllen;
+ cmsg->cmsg_len = CMSG_LEN(sizeof(int));
cmsg->cmsg_level = SOL_SOCKET;
cmsg->cmsg_type = SCM_RIGHTS;
*(int *)CMSG_DATA(cmsg) = buf->fd;
diff --git a/usr.sbin/bgpd/imsg.c b/usr.sbin/bgpd/imsg.c
index c9b964507f7..1e8255b130e 100644
--- a/usr.sbin/bgpd/imsg.c
+++ b/usr.sbin/bgpd/imsg.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: imsg.c,v 1.41 2008/03/15 16:25:00 deraadt Exp $ */
+/* $OpenBSD: imsg.c,v 1.42 2008/03/24 16:11:02 deraadt Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -57,7 +57,7 @@ imsg_read(struct imsgbuf *ibuf)
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
msg.msg_control = &cmsgbuf.buf;
- msg.msg_controllen = CMSG_LEN(sizeof(int) * 16);
+ msg.msg_controllen = sizeof(cmsgbuf.buf);
if ((n = recvmsg(ibuf->fd, &msg, 0)) == -1) {
if (errno != EINTR && errno != EAGAIN) {
diff --git a/usr.sbin/bind/lib/isc/unix/privsep_fdpass.c b/usr.sbin/bind/lib/isc/unix/privsep_fdpass.c
index 444889a8074..5a59e0bda73 100644
--- a/usr.sbin/bind/lib/isc/unix/privsep_fdpass.c
+++ b/usr.sbin/bind/lib/isc/unix/privsep_fdpass.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: privsep_fdpass.c,v 1.6 2008/03/15 16:33:58 deraadt Exp $ */
+/* $OpenBSD: privsep_fdpass.c,v 1.7 2008/03/24 16:11:02 deraadt Exp $ */
/*
* Copyright 2001 Niels Provos <provos@citi.umich.edu>
@@ -61,7 +61,7 @@ send_fd(int sock, int fd)
if (fd >= 0) {
msg.msg_control = (caddr_t)&cmsgbuf.buf;
- msg.msg_controllen = CMSG_LEN(sizeof(int));
+ msg.msg_controllen = sizeof(cmsgbuf.buf);
cmsg = CMSG_FIRSTHDR(&msg);
cmsg->cmsg_len = CMSG_LEN(sizeof(int));
cmsg->cmsg_level = SOL_SOCKET;
@@ -102,7 +102,7 @@ receive_fd(int sock)
msg.msg_iov = &vec;
msg.msg_iovlen = 1;
msg.msg_control = &cmsgbuf.buf;
- msg.msg_controllen = CMSG_LEN(sizeof(int));
+ msg.msg_controllen = sizeof(cmsgbuf.buf);
if ((n = recvmsg(sock, &msg, 0)) == -1)
warn("%s: recvmsg", __func__);
diff --git a/usr.sbin/bind/lib/isc/unix/socket.c b/usr.sbin/bind/lib/isc/unix/socket.c
index 74003115a47..5f6583dc5e4 100644
--- a/usr.sbin/bind/lib/isc/unix/socket.c
+++ b/usr.sbin/bind/lib/isc/unix/socket.c
@@ -190,10 +190,8 @@ struct isc_socket {
#endif
char *recvcmsgbuf;
- ISC_SOCKADDR_LEN_T recvcmsgbufspace;
ISC_SOCKADDR_LEN_T recvcmsgbuflen;
char *sendcmsgbuf;
- ISC_SOCKADDR_LEN_T sendcmsgbufspace;
ISC_SOCKADDR_LEN_T sendcmsgbuflen;
};
@@ -513,14 +511,11 @@ cmsg_space(ISC_SOCKADDR_LEN_T len) {
* XXX: The buffer length is an ad-hoc value, but should be enough
* in a practical sense.
*/
- union {
- struct cmsghdr hdr;
- char buf[cmsg_sizeof(struct cmsghdr) + 1024];
- };
+ char dummybuf[sizeof(struct cmsghdr) + 1024];
memset(&msg, 0, sizeof(msg));
msg.msg_control = dummybuf;
- msg.msg_controllen = cmsg_len(sizeof(cmsg_sizeof(struct cmsghdr) + 1024));
+ msg.msg_controllen = sizeof(dummybuf);
cmsgp = (struct cmsghdr *)dummybuf;
cmsgp->cmsg_len = cmsg_len(len);
@@ -726,7 +721,7 @@ build_msghdr_send(isc_socket_t *sock, isc_socketevent_t *dev,
"sendto pktinfo data, ifindex %u",
dev->pktinfo.ipi6_ifindex);
- msg->msg_controllen = cmsg_len(sizeof(struct in6_pktinfo));
+ msg->msg_controllen = cmsg_space(sizeof(struct in6_pktinfo));
INSIST(msg->msg_controllen <= sock->sendcmsgbuflen);
msg->msg_control = (void *)sock->sendcmsgbuf;
@@ -867,7 +862,7 @@ build_msghdr_recv(isc_socket_t *sock, isc_socketevent_t *dev,
msg->msg_flags = 0;
#if defined(USE_CMSG)
if (sock->type == isc_sockettype_udp) {
- msg->msg_control = sock->recvcmsgbuf;
+ msg->msg_control = sock->recvcmsgbuf;
msg->msg_controllen = sock->recvcmsgbuflen;
}
#endif /* USE_CMSG */
@@ -1262,7 +1257,7 @@ allocate_socket(isc_socketmgr_t *manager, isc_sockettype_t type,
{
isc_socket_t *sock;
isc_result_t result;
- ISC_SOCKADDR_LEN_T cmsgbuflen, cmsgbufspace;
+ ISC_SOCKADDR_LEN_T cmsgbuflen;
sock = isc_mem_get(manager->mctx, sizeof(*sock));
@@ -1287,33 +1282,26 @@ allocate_socket(isc_socketmgr_t *manager, isc_sockettype_t type,
* set up cmsg buffers
*/
cmsgbuflen = 0;
- cmsgbufspace = 0;
#if defined(USE_CMSG) && defined(ISC_PLATFORM_HAVEIN6PKTINFO)
- cmsgbuflen = cmsgbufspace + cmsg_len(sizeof(struct in6_pktinfo));
- cmsgbufspace += cmsg_space(sizeof(struct in6_pktinfo));
+ cmsgbuflen = cmsg_space(sizeof(struct in6_pktinfo));
#endif
#if defined(USE_CMSG) && defined(SO_TIMESTAMP)
- cmsgbuflen = cmsgbufspace + cmsg_len(sizeof(struct timeval));
- cmsgbufspace += cmsg_space(sizeof(struct timeval));
+ cmsgbuflen += cmsg_space(sizeof(struct timeval));
#endif
sock->recvcmsgbuflen = cmsgbuflen;
- sock->recvcmsgbufspace = cmsgbufspace;
- if (sock->recvcmsgbufspace != 0U) {
- sock->recvcmsgbuf = isc_mem_get(manager->mctx, cmsgbufspace);
+ if (sock->recvcmsgbuflen != 0U) {
+ sock->recvcmsgbuf = isc_mem_get(manager->mctx, cmsgbuflen);
if (sock->recvcmsgbuf == NULL)
goto error;
}
cmsgbuflen = 0;
- cmsgbufspace = 0;
#if defined(USE_CMSG) && defined(ISC_PLATFORM_HAVEIN6PKTINFO)
- cmsgbuflen = cmsgbufspace + cmsg_len(sizeof(struct in6_pktinfo));
- cmsgbufspace += cmsg_space(sizeof(struct in6_pktinfo));
+ cmsgbuflen = cmsg_space(sizeof(struct in6_pktinfo));
#endif
sock->sendcmsgbuflen = cmsgbuflen;
- sock->sendcmsgbufspace = cmsgbufspace;
if (sock->sendcmsgbuflen != 0U) {
- sock->sendcmsgbuf = isc_mem_get(manager->mctx, cmsgbufspace);
+ sock->sendcmsgbuf = isc_mem_get(manager->mctx, cmsgbuflen);
if (sock->sendcmsgbuf == NULL)
goto error;
}
@@ -1360,10 +1348,10 @@ allocate_socket(isc_socketmgr_t *manager, isc_sockettype_t type,
error:
if (sock->recvcmsgbuf != NULL)
isc_mem_put(manager->mctx, sock->recvcmsgbuf,
- sock->recvcmsgbufspace);
+ sock->recvcmsgbuflen);
if (sock->sendcmsgbuf != NULL)
isc_mem_put(manager->mctx, sock->sendcmsgbuf,
- sock->sendcmsgbufspace);
+ sock->sendcmsgbuflen);
isc_mem_put(manager->mctx, sock, sizeof(*sock));
return (result);
@@ -1393,10 +1381,10 @@ free_socket(isc_socket_t **socketp) {
if (sock->recvcmsgbuf != NULL)
isc_mem_put(sock->manager->mctx, sock->recvcmsgbuf,
- sock->recvcmsgbufspace);
+ sock->recvcmsgbuflen);
if (sock->sendcmsgbuf != NULL)
isc_mem_put(sock->manager->mctx, sock->sendcmsgbuf,
- sock->sendcmsgbufspace);
+ sock->sendcmsgbuflen);
sock->magic = 0;
diff --git a/usr.sbin/ospf6d/packet.c b/usr.sbin/ospf6d/packet.c
index d6d5e63edb9..4bea8456228 100644
--- a/usr.sbin/ospf6d/packet.c
+++ b/usr.sbin/ospf6d/packet.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: packet.c,v 1.8 2008/03/15 16:25:00 deraadt Exp $ */
+/* $OpenBSD: packet.c,v 1.9 2008/03/24 16:11:04 deraadt Exp $ */
/*
* Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
@@ -147,7 +147,7 @@ recv_packet(int fd, short event, void *bula)
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
msg.msg_control = &cmsgbuf.buf;
- msg.msg_controllen = CMSG_LEN(sizeof(struct in6_pktinfo));
+ msg.msg_controllen = sizeof(cmsgbuf.buf);
if ((r = recvmsg(fd, &msg, 0)) == -1) {
if (errno != EAGAIN && errno != EINTR)
diff --git a/usr.sbin/ospfd/packet.c b/usr.sbin/ospfd/packet.c
index d39e142db75..13aef3cdc51 100644
--- a/usr.sbin/ospfd/packet.c
+++ b/usr.sbin/ospfd/packet.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: packet.c,v 1.24 2008/03/15 16:25:00 deraadt Exp $ */
+/* $OpenBSD: packet.c,v 1.25 2008/03/24 16:11:04 deraadt Exp $ */
/*
* Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
@@ -140,7 +140,7 @@ recv_packet(int fd, short event, void *bula)
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
msg.msg_control = &cmsgbuf.buf;
- msg.msg_controllen = CMSG_LEN(sizeof(struct sockaddr_dl));
+ msg.msg_controllen = sizeof(cmsgbuf.buf);
if ((r = recvmsg(fd, &msg, 0)) == -1) {
if (errno != EAGAIN && errno != EINTR)
diff --git a/usr.sbin/ppp/ppp/bundle.c b/usr.sbin/ppp/ppp/bundle.c
index fd18a89d4ee..c64db887386 100644
--- a/usr.sbin/ppp/ppp/bundle.c
+++ b/usr.sbin/ppp/ppp/bundle.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $OpenBSD: bundle.c,v 1.73 2008/03/15 16:25:00 deraadt Exp $
+ * $OpenBSD: bundle.c,v 1.74 2008/03/24 16:11:04 deraadt Exp $
*/
#include <sys/param.h>
@@ -1418,7 +1418,7 @@ bundle_ReceiveDatalink(struct bundle *bundle, int s)
msg.msg_iov = iov;
msg.msg_iovlen = 1; /* Only send the version at the first pass */
msg.msg_control = cmsgbuf.buf;
- msg.msg_controllen = CMSG_LEN(sizeof(int) * SEND_MAXFD);
+ msg.msg_controllen = sizeof(cmsgbuf.buf);
cmsg = CMSG_FIRSTHDR(&msg);
cmsg->cmsg_len = sizeof cmsgbuf.buf;
cmsg->cmsg_level = SOL_SOCKET;
@@ -1591,7 +1591,7 @@ bundle_SendDatalink(struct datalink *dl, int s, struct sockaddr_un *sun)
msg.msg_iovlen = 1;
msg.msg_iov = iov;
msg.msg_control = &cmsgbuf.buf;
- msg.msg_controllen = CMSG_LEN(sizeof(int) * nfd);
+ msg.msg_controllen = CMSG_SPACE(sizeof(int) * nfd);
msg.msg_flags = 0;
cmsg = CMSG_FIRSTHDR(&msg);
cmsg->cmsg_len = msg.msg_controllen;
diff --git a/usr.sbin/relayd/buffer.c b/usr.sbin/relayd/buffer.c
index 52f5bac4465..60a39d07e05 100644
--- a/usr.sbin/relayd/buffer.c
+++ b/usr.sbin/relayd/buffer.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: buffer.c,v 1.11 2008/03/15 16:19:02 deraadt Exp $ */
+/* $OpenBSD: buffer.c,v 1.12 2008/03/24 16:11:05 deraadt Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -181,7 +181,7 @@ msgbuf_write(struct msgbuf *msgbuf)
if (buf != NULL && buf->fd != -1) {
msg.msg_control = (caddr_t)&cmsgbuf.buf;
- msg.msg_controllen = CMSG_LEN(sizeof(int));
+ msg.msg_controllen = sizeof(cmsgbuf.buf);
cmsg = CMSG_FIRSTHDR(&msg);
cmsg->cmsg_len = CMSG_LEN(sizeof(int));
cmsg->cmsg_level = SOL_SOCKET;
@@ -204,7 +204,7 @@ msgbuf_write(struct msgbuf *msgbuf)
if (buf != NULL && buf->fd != -1) {
msg.msg_control = (caddr_t)&cmsgbuf.buf;
- msg.msg_controllen = CMSG_LEN(sizeof(int));
+ msg.msg_controllen = sizeof(cmsgbuf.buf);
cmsg = CMSG_FIRSTHDR(&msg);
cmsg->cmsg_len = CMSG_LEN(sizeof(int));
cmsg->cmsg_level = SOL_SOCKET;
diff --git a/usr.sbin/relayd/imsg.c b/usr.sbin/relayd/imsg.c
index d42dc9c252f..c65f4b6d92c 100644
--- a/usr.sbin/relayd/imsg.c
+++ b/usr.sbin/relayd/imsg.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: imsg.c,v 1.13 2008/03/15 16:25:00 deraadt Exp $ */
+/* $OpenBSD: imsg.c,v 1.14 2008/03/24 16:11:05 deraadt Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -68,7 +68,7 @@ imsg_read(struct imsgbuf *ibuf)
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
msg.msg_control = &cmsgbuf.buf;
- msg.msg_controllen = CMSG_LEN(sizeof(int) * 16);
+ msg.msg_controllen = sizeof(cmsgbuf.buf);
if ((n = recvmsg(ibuf->fd, &msg, 0)) == -1) {
if (errno != EINTR && errno != EAGAIN) {
diff --git a/usr.sbin/ripd/packet.c b/usr.sbin/ripd/packet.c
index 697abf93e69..7447baee48c 100644
--- a/usr.sbin/ripd/packet.c
+++ b/usr.sbin/ripd/packet.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: packet.c,v 1.9 2008/03/15 16:24:58 deraadt Exp $ */
+/* $OpenBSD: packet.c,v 1.10 2008/03/24 16:11:05 deraadt Exp $ */
/*
* Copyright (c) 2006 Michele Marchetto <mydecay@openbeer.it>
@@ -113,7 +113,7 @@ recv_packet(int fd, short event, void *bula)
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
msg.msg_control = &cmsgbuf.buf;
- msg.msg_controllen = CMSG_LEN(sizeof(struct sockaddr_dl));
+ msg.msg_controllen = sizeof(cmsgbuf.buf);
if ((r = recvmsg(fd, &msg, 0)) == -1) {
if (errno != EINTR && errno != EAGAIN)
diff --git a/usr.sbin/route6d/route6d.c b/usr.sbin/route6d/route6d.c
index 4b67a6cfa0b..12f7bf9259c 100644
--- a/usr.sbin/route6d/route6d.c
+++ b/usr.sbin/route6d/route6d.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: route6d.c,v 1.50 2008/03/15 16:23:27 deraadt Exp $ */
+/* $OpenBSD: route6d.c,v 1.51 2008/03/24 16:11:05 deraadt Exp $ */
/* $KAME: route6d.c,v 1.111 2006/10/25 06:38:13 jinmei Exp $ */
/*
@@ -31,7 +31,7 @@
*/
#if 0
-static char _rcsid[] = "$OpenBSD: route6d.c,v 1.50 2008/03/15 16:23:27 deraadt Exp $";
+static char _rcsid[] = "$OpenBSD: route6d.c,v 1.51 2008/03/24 16:11:05 deraadt Exp $";
#endif
#include <stdio.h>
@@ -965,7 +965,7 @@ sendpacket(struct sockaddr_in6 *sin6, int len)
} else {
memset(&cmsgbuf, 0, sizeof(cmsgbuf));
m.msg_control = (caddr_t)&cmsgbuf.buf;
- m.msg_controllen = CMSG_LEN(sizeof(struct in6_pktinfo));
+ m.msg_controllen = sizeof(cmsgbuf.buf);
cm = CMSG_FIRSTHDR(&m);
cm->cmsg_len = CMSG_LEN(sizeof(struct in6_pktinfo));
cm->cmsg_level = IPPROTO_IPV6;
@@ -1023,7 +1023,7 @@ riprecv(void)
m.msg_iov = iov;
m.msg_iovlen = 1;
m.msg_control = (caddr_t)&cmsgbuf.buf;
- m.msg_controllen = CMSG_LEN(sizeof(struct in6_pktinfo));
+ m.msg_controllen = sizeof(cmsgbuf.buf);
if ((len = recvmsg(ripsock, &m, 0)) < 0) {
fatal("recvmsg");
/*NOTREACHED*/
diff --git a/usr.sbin/rtadvd/rtadvd.c b/usr.sbin/rtadvd/rtadvd.c
index 1738f3e662b..fa597f56df4 100644
--- a/usr.sbin/rtadvd/rtadvd.c
+++ b/usr.sbin/rtadvd/rtadvd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtadvd.c,v 1.29 2008/03/18 19:32:18 deraadt Exp $ */
+/* $OpenBSD: rtadvd.c,v 1.30 2008/03/24 16:11:05 deraadt Exp $ */
/* $KAME: rtadvd.c,v 1.66 2002/05/29 14:18:36 itojun Exp $ */
/*
@@ -67,10 +67,8 @@
struct msghdr rcvmhdr;
static u_char *rcvcmsgbuf;
-static size_t rcvcmsgbufspace;
static size_t rcvcmsgbuflen;
static u_char *sndcmsgbuf = NULL;
-static size_t sndcmsgbufspace;
static size_t sndcmsgbuflen;
volatile sig_atomic_t do_dump;
volatile sig_atomic_t do_die;
@@ -1297,20 +1295,16 @@ sock_open()
static u_char answer[1500];
rcvcmsgbuflen = CMSG_SPACE(sizeof(struct in6_pktinfo)) +
- CMSG_LEN(sizeof(int));
- rcvcmsgbufspace = CMSG_SPACE(sizeof(struct in6_pktinfo)) +
CMSG_SPACE(sizeof(int));
- rcvcmsgbuf = (u_char *)malloc(rcvcmsgbufspace);
+ rcvcmsgbuf = (u_char *)malloc(rcvcmsgbuflen);
if (rcvcmsgbuf == NULL) {
syslog(LOG_ERR, "<%s> not enough core", __func__);
exit(1);
}
sndcmsgbuflen = CMSG_SPACE(sizeof(struct in6_pktinfo)) +
- CMSG_LEN(sizeof(int));
- sndcmsgbufspace = CMSG_SPACE(sizeof(struct in6_pktinfo)) +
CMSG_SPACE(sizeof(int));
- sndcmsgbuf = (u_char *)malloc(sndcmsgbufspace);
+ sndcmsgbuf = (u_char *)malloc(sndcmsgbuflen);
if (sndcmsgbuf == NULL) {
syslog(LOG_ERR, "<%s> not enough core", __func__);
exit(1);
diff --git a/usr.sbin/rtsold/probe.c b/usr.sbin/rtsold/probe.c
index 33720656bc5..172c6fe7d5c 100644
--- a/usr.sbin/rtsold/probe.c
+++ b/usr.sbin/rtsold/probe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: probe.c,v 1.11 2008/03/18 19:32:19 deraadt Exp $ */
+/* $OpenBSD: probe.c,v 1.12 2008/03/24 16:11:05 deraadt Exp $ */
/* $KAME: probe.c,v 1.16 2002/06/10 20:00:36 itojun Exp $ */
/*
@@ -64,13 +64,11 @@ int
probe_init(void)
{
int scmsglen = CMSG_SPACE(sizeof(struct in6_pktinfo)) +
- CMSG_LEN(sizeof(int));
- int scmsgspace = CMSG_SPACE(sizeof(struct in6_pktinfo)) +
CMSG_SPACE(sizeof(int));
static u_char *sndcmsgbuf = NULL;
if (sndcmsgbuf == NULL &&
- (sndcmsgbuf = (u_char *)malloc(scmsgspace)) == NULL) {
+ (sndcmsgbuf = (u_char *)malloc(scmsglen)) == NULL) {
warnmsg(LOG_ERR, __func__, "malloc failed");
return(-1);
}
diff --git a/usr.sbin/rtsold/rtsol.c b/usr.sbin/rtsold/rtsol.c
index fe2988826d4..1cab663b690 100644
--- a/usr.sbin/rtsold/rtsol.c
+++ b/usr.sbin/rtsold/rtsol.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtsol.c,v 1.13 2008/03/18 19:32:19 deraadt Exp $ */
+/* $OpenBSD: rtsol.c,v 1.14 2008/03/24 16:11:05 deraadt Exp $ */
/* $KAME: rtsol.c,v 1.15 2002/05/31 10:10:03 itojun Exp $ */
/*
@@ -73,20 +73,18 @@ int
sockopen(void)
{
static u_char *rcvcmsgbuf = NULL, *sndcmsgbuf = NULL;
- int rcvcmsgspace, sndcmsgspace, rcvcmsglen, sndcmsglen, on;
+ int rcvcmsglen, sndcmsglen, on;
static u_char answer[1500];
struct icmp6_filter filt;
sndcmsglen = rcvcmsglen = CMSG_SPACE(sizeof(struct in6_pktinfo)) +
- CMSG_LEN(sizeof(int));
- sndcmsgspace = rcvcmsgspace = CMSG_SPACE(sizeof(struct in6_pktinfo)) +
CMSG_SPACE(sizeof(int));
- if (rcvcmsgbuf == NULL && (rcvcmsgbuf = malloc(rcvcmsgspace)) == NULL) {
+ if (rcvcmsgbuf == NULL && (rcvcmsgbuf = malloc(rcvcmsglen)) == NULL) {
warnmsg(LOG_ERR, __func__,
"malloc for receive msghdr failed");
return(-1);
}
- if (sndcmsgbuf == NULL && (sndcmsgbuf = malloc(sndcmsgspace)) == NULL) {
+ if (sndcmsgbuf == NULL && (sndcmsgbuf = malloc(sndcmsglen)) == NULL) {
warnmsg(LOG_ERR, __func__,
"malloc for send msghdr failed");
return(-1);
diff --git a/usr.sbin/snmpd/buffer.c b/usr.sbin/snmpd/buffer.c
index 361746cad07..407bbb8c00f 100644
--- a/usr.sbin/snmpd/buffer.c
+++ b/usr.sbin/snmpd/buffer.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: buffer.c,v 1.3 2008/03/15 16:19:02 deraadt Exp $ */
+/* $OpenBSD: buffer.c,v 1.4 2008/03/24 16:11:05 deraadt Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -181,7 +181,7 @@ msgbuf_write(struct msgbuf *msgbuf)
if (buf != NULL && buf->fd != -1) {
msg.msg_control = (caddr_t)&cmsgbuf.buf;
- msg.msg_controllen = CMSG_LEN(sizeof(int));
+ msg.msg_controllen = sizeof(cmsgbuf.buf);
cmsg = CMSG_FIRSTHDR(&msg);
cmsg->cmsg_len = CMSG_LEN(sizeof(int));
cmsg->cmsg_level = SOL_SOCKET;
@@ -204,7 +204,7 @@ msgbuf_write(struct msgbuf *msgbuf)
if (buf != NULL && buf->fd != -1) {
msg.msg_control = (caddr_t)&cmsgbuf.buf;
- msg.msg_controllen = CMSG_LEN(sizeof(int));
+ msg.msg_controllen = sizeof(cmsgbuf.buf);
cmsg = CMSG_FIRSTHDR(&msg);
cmsg->cmsg_len = CMSG_LEN(sizeof(int));
cmsg->cmsg_level = SOL_SOCKET;
diff --git a/usr.sbin/snmpd/imsg.c b/usr.sbin/snmpd/imsg.c
index 821036f86b6..a7671183bec 100644
--- a/usr.sbin/snmpd/imsg.c
+++ b/usr.sbin/snmpd/imsg.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: imsg.c,v 1.4 2008/03/15 16:19:02 deraadt Exp $ */
+/* $OpenBSD: imsg.c,v 1.5 2008/03/24 16:11:05 deraadt Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -68,7 +68,7 @@ imsg_read(struct imsgbuf *ibuf)
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
msg.msg_control = &cmsgbuf.buf;
- msg.msg_controllen = CMSG_LEN(sizeof(int) * 16);
+ msg.msg_controllen = sizeof(cmsgbuf.buf);
if ((n = recvmsg(ibuf->fd, &msg, 0)) == -1) {
if (errno != EINTR && errno != EAGAIN) {
diff --git a/usr.sbin/syslogd/privsep_fdpass.c b/usr.sbin/syslogd/privsep_fdpass.c
index 03105f9835d..a9a2e6a1b7e 100644
--- a/usr.sbin/syslogd/privsep_fdpass.c
+++ b/usr.sbin/syslogd/privsep_fdpass.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: privsep_fdpass.c,v 1.6 2008/03/15 16:19:02 deraadt Exp $ */
+/* $OpenBSD: privsep_fdpass.c,v 1.7 2008/03/24 16:11:05 deraadt Exp $ */
/*
* Copyright 2001 Niels Provos <provos@citi.umich.edu>
@@ -63,7 +63,7 @@ send_fd(int sock, int fd)
if (fd >= 0) {
msg.msg_control = (caddr_t)&cmsgbuf.buf;
- msg.msg_controllen = CMSG_LEN(sizeof(int));
+ msg.msg_controllen = sizeof(cmsgbuf.buf);
cmsg = CMSG_FIRSTHDR(&msg);
cmsg->cmsg_len = CMSG_LEN(sizeof(int));
cmsg->cmsg_level = SOL_SOCKET;
@@ -105,7 +105,7 @@ receive_fd(int sock)
msg.msg_iov = &vec;
msg.msg_iovlen = 1;
msg.msg_control = &cmsgbuf.buf;
- msg.msg_controllen = CMSG_LEN(sizeof(int));
+ msg.msg_controllen = sizeof(cmsgbuf.buf);
if ((n = recvmsg(sock, &msg, 0)) == -1)
warn("%s: recvmsg", "receive_fd");
diff --git a/usr.sbin/tcpdump/privsep_fdpass.c b/usr.sbin/tcpdump/privsep_fdpass.c
index bba8d85e4b9..203ba07c324 100644
--- a/usr.sbin/tcpdump/privsep_fdpass.c
+++ b/usr.sbin/tcpdump/privsep_fdpass.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: privsep_fdpass.c,v 1.6 2008/03/15 16:19:02 deraadt Exp $ */
+/* $OpenBSD: privsep_fdpass.c,v 1.7 2008/03/24 16:11:06 deraadt Exp $ */
/*
* Copyright (c) 2002 Matthieu Herrb
@@ -46,7 +46,7 @@ send_fd(int sock, int fd)
if (fd >= 0) {
msg.msg_control = (caddr_t)&cmsgbuf.buf;
- msg.msg_controllen = CMSG_LEN(sizeof(int));
+ msg.msg_controllen = sizeof(cmsgbuf.buf);
cmsg = CMSG_FIRSTHDR(&msg);
cmsg->cmsg_len = CMSG_LEN(sizeof(int));
cmsg->cmsg_level = SOL_SOCKET;
@@ -87,7 +87,7 @@ receive_fd(int sock)
msg.msg_iov = &vec;
msg.msg_iovlen = 1;
msg.msg_control = &cmsgbuf.buf;
- msg.msg_controllen = CMSG_LEN(sizeof(int));
+ msg.msg_controllen = sizeof(cmsgbuf.buf);
if ((n = recvmsg(sock, &msg, 0)) == -1)
warn("%s: recvmsg", __func__);
diff --git a/usr.sbin/traceroute6/traceroute6.c b/usr.sbin/traceroute6/traceroute6.c
index b2647fb80c4..af4a4b9c452 100644
--- a/usr.sbin/traceroute6/traceroute6.c
+++ b/usr.sbin/traceroute6/traceroute6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: traceroute6.c,v 1.44 2008/03/15 16:43:59 deraadt Exp $ */
+/* $OpenBSD: traceroute6.c,v 1.45 2008/03/24 16:11:06 deraadt Exp $ */
/* $KAME: traceroute6.c,v 1.63 2002/10/24 12:53:25 itojun Exp $ */
/*
@@ -344,7 +344,7 @@ main(int argc, char *argv[])
{
int mib[4] = { CTL_NET, PF_INET6, IPPROTO_IPV6, IPV6CTL_DEFHLIM };
char hbuf[NI_MAXHOST], src0[NI_MAXHOST], *ep;
- int ch, i, on = 1, seq, rcvcmsglen, rcvcmsgspace, error, minlen;
+ int ch, i, on = 1, seq, rcvcmsglen, error, minlen;
struct addrinfo hints, *res;
static u_char *rcvcmsgbuf;
u_long probe, hops, lport;
@@ -590,12 +590,10 @@ main(int argc, char *argv[])
rcvmhdr.msg_namelen = sizeof(Rcv);
rcvmhdr.msg_iov = rcviov;
rcvmhdr.msg_iovlen = 1;
- rcvcmsgspace = CMSG_SPACE(sizeof(struct in6_pktinfo)) +
- CMSG_SPACE(sizeof(int));
rcvcmsglen = CMSG_SPACE(sizeof(struct in6_pktinfo)) +
- CMSG_LEN(sizeof(int));
+ CMSG_SPACE(sizeof(int));
- if ((rcvcmsgbuf = malloc(rcvcmsgspace)) == NULL) {
+ if ((rcvcmsgbuf = malloc(rcvcmsglen)) == NULL) {
fprintf(stderr, "traceroute6: malloc failed\n");
exit(1);
}