summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gnu/usr.bin/perl/perl.c4
-rw-r--r--kerberosV/src/kcm/connect.c11
-rw-r--r--lib/libc/gen/auth_subr.c4
-rw-r--r--libexec/ftpd/monitor_fdpass.c6
-rw-r--r--libexec/login_skey/login_skey.c4
-rw-r--r--libexec/login_tis/login_tis.c4
-rw-r--r--libexec/tftp-proxy/tftp-proxy.c4
-rw-r--r--libexec/tftpd/tftpd.c8
-rw-r--r--regress/sys/kern/unfdpass/unfdpass.c6
-rw-r--r--sbin/isakmpd/monitor_fdpass.c6
-rw-r--r--sbin/mount_portal/activate.c4
-rw-r--r--sbin/pflogd/privsep_fdpass.c6
-rw-r--r--sbin/ping6/ping6.c29
-rw-r--r--share/man/man3/CMSG_DATA.313
-rw-r--r--usr.bin/ssh/monitor_fdpass.c6
-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
34 files changed, 118 insertions, 151 deletions
diff --git a/gnu/usr.bin/perl/perl.c b/gnu/usr.bin/perl/perl.c
index c9799f0b349..1674458edd5 100644
--- a/gnu/usr.bin/perl/perl.c
+++ b/gnu/usr.bin/perl/perl.c
@@ -451,7 +451,7 @@ Perl_dump_sv_child(pTHX_ SV *sv)
be open, the wait would be forever. */
msg.msg_control = control.control;
- msg.msg_controllen = CMSG_LEN(sizeof(int));
+ msg.msg_controllen = sizeof(control.control);
/* We're a connected socket so we don't need a destination */
msg.msg_name = NULL;
msg.msg_namelen = 0;
@@ -716,7 +716,7 @@ perl_destruct(pTHXx)
int got_fd;
msg.msg_control = control.control;
- msg.msg_controllen = CMSG_LEN(sizeof(int));
+ msg.msg_controllen = sizeof(control.control);
/* We're a connected socket so we don't need a source */
msg.msg_name = NULL;
msg.msg_namelen = 0;
diff --git a/kerberosV/src/kcm/connect.c b/kerberosV/src/kcm/connect.c
index 559453c224a..739e2b13871 100644
--- a/kerberosV/src/kcm/connect.c
+++ b/kerberosV/src/kcm/connect.c
@@ -143,25 +143,24 @@ update_client_creds(int s, kcm_client *peer)
/* NetBSD */
if (peer->uid == -1) {
struct msghdr msg;
- socklen_t crmsgspace, crmsglen;
+ socklen_t crmsgsize;
void *crmsg;
struct cmsghdr *cmp;
struct sockcred *sc;
memset(&msg, 0, sizeof(msg));
- crmsgspace = CMSG_SPACE(SOCKCREDSIZE(NGROUPS));
- crmsglen = CMSG_LEN(SOCKCREDSIZE(NGROUPS));
+ crmsgsize = CMSG_SPACE(SOCKCREDSIZE(NGROUPS));
if (crmsgsize == 0)
return 1 ;
- crmsg = malloc(crmsgspace);
+ crmsg = malloc(crmsgsize);
if (crmsg == NULL)
goto failed_scm_creds;
- memset(crmsg, 0, crmsgspace);
+ memset(crmsg, 0, crmsgsize);
msg.msg_control = crmsg;
- msg.msg_controllen = crmsglen;
+ msg.msg_controllen = crmsgsize;
if (recvmsg(s, &msg, 0) < 0) {
free(crmsg);
diff --git a/lib/libc/gen/auth_subr.c b/lib/libc/gen/auth_subr.c
index 405215c7216..73d5bff7581 100644
--- a/lib/libc/gen/auth_subr.c
+++ b/lib/libc/gen/auth_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: auth_subr.c,v 1.34 2008/03/15 16:19:02 deraadt Exp $ */
+/* $OpenBSD: auth_subr.c,v 1.35 2008/03/24 16:10:59 deraadt Exp $ */
/*
* Copyright (c) 2000-2002,2004 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -995,7 +995,7 @@ _recv_fd(auth_session_t *as, int fd)
memset(&msg, 0, sizeof(msg));
msg.msg_control = &cmsgbuf.buf;
- msg.msg_controllen = CMSG_LEN(sizeof(int));
+ msg.msg_controllen = sizeof(cmsgbuf.buf);
if (recvmsg(fd, &msg, 0) < 0)
syslog(LOG_ERR, "recvmsg: %m");
else if (msg.msg_flags & MSG_TRUNC)
diff --git a/libexec/ftpd/monitor_fdpass.c b/libexec/ftpd/monitor_fdpass.c
index 94d116eadb6..f4923a1267a 100644
--- a/libexec/ftpd/monitor_fdpass.c
+++ b/libexec/ftpd/monitor_fdpass.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: monitor_fdpass.c,v 1.3 2008/03/15 16:19:02 deraadt Exp $ */
+/* $OpenBSD: monitor_fdpass.c,v 1.4 2008/03/24 16:11:00 deraadt Exp $ */
/*
* Copyright (c) 2002 Matthieu Herrb
@@ -44,7 +44,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;
@@ -85,7 +85,7 @@ recv_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)
syslog(LOG_WARNING, "recv_fd: recvmsg(%d): %m", sock);
diff --git a/libexec/login_skey/login_skey.c b/libexec/login_skey/login_skey.c
index a47c162b9b3..b41dac6e06f 100644
--- a/libexec/login_skey/login_skey.c
+++ b/libexec/login_skey/login_skey.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: login_skey.c,v 1.21 2008/03/15 16:19:02 deraadt Exp $ */
+/* $OpenBSD: login_skey.c,v 1.22 2008/03/24 16:11:00 deraadt Exp $ */
/*
* Copyright (c) 2000, 2001, 2004 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -270,7 +270,7 @@ send_fd(int sock)
memset(&msg, 0, sizeof(msg));
msg.msg_control = &cmsgbuf.buf;
- msg.msg_controllen = CMSG_LEN(sizeof(int));
+ msg.msg_controllen = sizeof(cmsgbuf.buf);
cmp = CMSG_FIRSTHDR(&msg);
cmp->cmsg_len = CMSG_LEN(sizeof(int));
diff --git a/libexec/login_tis/login_tis.c b/libexec/login_tis/login_tis.c
index 25792b28213..ce8bc9c2a54 100644
--- a/libexec/login_tis/login_tis.c
+++ b/libexec/login_tis/login_tis.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: login_tis.c,v 1.8 2008/03/15 16:19:02 deraadt Exp $ */
+/* $OpenBSD: login_tis.c,v 1.9 2008/03/24 16:11:00 deraadt Exp $ */
/*
* Copyright (c) 2004 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -296,7 +296,7 @@ send_fd(struct tis_connection *tc, int sock)
memset(&msg, 0, sizeof(msg));
msg.msg_control = &cmsgbuf.buf;
- msg.msg_controllen = CMSG_LEN(sizeof(int));
+ msg.msg_controllen = sizeof(cmsgbuf.buf);
cmp = CMSG_FIRSTHDR(&msg);
cmp->cmsg_len = CMSG_LEN(sizeof(int));
diff --git a/libexec/tftp-proxy/tftp-proxy.c b/libexec/tftp-proxy/tftp-proxy.c
index af1b35dbd69..52db0d683c7 100644
--- a/libexec/tftp-proxy/tftp-proxy.c
+++ b/libexec/tftp-proxy/tftp-proxy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tftp-proxy.c,v 1.4 2008/03/15 16:25:00 deraadt Exp $
+/* $OpenBSD: tftp-proxy.c,v 1.5 2008/03/24 16:11:00 deraadt Exp $
*
* Copyright (c) 2005 DLS Internet Services
* Copyright (c) 2004, 2005 Camiel Dobbelaar, <cd@sentia.nl>
@@ -164,7 +164,7 @@ main(int argc, char *argv[])
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
msg.msg_control = &cmsgbuf.buf;
- msg.msg_controllen = CMSG_LEN(sizeof(struct sockaddr_storage));
+ msg.msg_controllen = sizeof(cmsgbuf.buf);
if (recvmsg(fd, &msg, 0) < 0) {
syslog(LOG_ERR, "recvmsg: %m");
diff --git a/libexec/tftpd/tftpd.c b/libexec/tftpd/tftpd.c
index 0fe4c9c1535..0a30406ba45 100644
--- a/libexec/tftpd/tftpd.c
+++ b/libexec/tftpd/tftpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tftpd.c,v 1.61 2008/03/15 16:25:00 deraadt Exp $ */
+/* $OpenBSD: tftpd.c,v 1.62 2008/03/24 16:11:00 deraadt Exp $ */
/*
* Copyright (c) 1983 Regents of the University of California.
@@ -37,7 +37,7 @@ char copyright[] =
#ifndef lint
/*static char sccsid[] = "from: @(#)tftpd.c 5.13 (Berkeley) 2/26/91";*/
-static char rcsid[] = "$OpenBSD: tftpd.c,v 1.61 2008/03/15 16:25:00 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: tftpd.c,v 1.62 2008/03/24 16:11:00 deraadt Exp $";
#endif /* not lint */
/*
@@ -286,7 +286,7 @@ main(int argc, char *argv[])
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
msg.msg_control = &cmsgbuf.buf;
- msg.msg_controllen = CMSG_LEN(sizeof(struct sockaddr_storage));
+ msg.msg_controllen = sizeof(cmsgbuf.buf);
n = recvmsg(fd, &msg, 0);
if (n < 0) {
@@ -330,7 +330,7 @@ main(int argc, char *argv[])
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
msg.msg_control = &cmsgbuf.buf;
- msg.msg_controllen = CMSG_LEN(sizeof(struct sockaddr_storage));
+ msg.msg_controllen = sizeof(cmsgbuf.buf);
i = recvmsg(fd, &msg, 0);
if (i > 0)
diff --git a/regress/sys/kern/unfdpass/unfdpass.c b/regress/sys/kern/unfdpass/unfdpass.c
index 80e6b0ec8fd..68bbad88bfc 100644
--- a/regress/sys/kern/unfdpass/unfdpass.c
+++ b/regress/sys/kern/unfdpass/unfdpass.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: unfdpass.c,v 1.14 2008/03/15 16:49:15 hshoexer Exp $ */
+/* $OpenBSD: unfdpass.c,v 1.15 2008/03/24 16:11:08 deraadt Exp $ */
/* $NetBSD: unfdpass.c,v 1.3 1998/06/24 23:51:30 thorpej Exp $ */
/*-
@@ -173,7 +173,7 @@ main(int argc, char *argv[])
*/
(void) memset(&msg, 0, sizeof(msg));
msg.msg_control = &cmsgbuf.buf;
- msg.msg_controllen = CMSG_LEN(sizeof(int) * 3);
+ msg.msg_controllen = sizeof(cmsgbuf.buf);
if (recvmsg(sock, &msg, 0) < 0)
err(1, "recvmsg");
@@ -270,7 +270,7 @@ child(int sock)
(void) memset(&msg, 0, sizeof(msg));
msg.msg_control = &cmsgbuf.buf;
- msg.msg_controllen = CMSG_LEN(sizeof(int) * 3);
+ msg.msg_controllen = sizeof(cmsgbuf.buf);
cmp = CMSG_FIRSTHDR(&msg);
cmp->cmsg_len = CMSG_LEN(sizeof(int) * 3);
diff --git a/sbin/isakmpd/monitor_fdpass.c b/sbin/isakmpd/monitor_fdpass.c
index c12af7db584..50e3f354655 100644
--- a/sbin/isakmpd/monitor_fdpass.c
+++ b/sbin/isakmpd/monitor_fdpass.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: monitor_fdpass.c,v 1.15 2008/03/15 16:19:02 deraadt Exp $ */
+/* $OpenBSD: monitor_fdpass.c,v 1.16 2008/03/24 16:11:08 deraadt Exp $ */
/*
* Copyright 2001 Niels Provos <provos@citi.umich.edu>
@@ -50,7 +50,7 @@ mm_send_fd(int socket, int fd)
bzero(&msg, sizeof msg);
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;
@@ -94,7 +94,7 @@ mm_receive_fd(int socket)
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(socket, &msg, 0)) == -1) {
log_error("mm_receive_fd: recvmsg");
diff --git a/sbin/mount_portal/activate.c b/sbin/mount_portal/activate.c
index e7ee78da4d4..8937cc785e4 100644
--- a/sbin/mount_portal/activate.c
+++ b/sbin/mount_portal/activate.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: activate.c,v 1.8 2008/03/15 16:19:02 deraadt Exp $ */
+/* $OpenBSD: activate.c,v 1.9 2008/03/24 16:11:08 deraadt Exp $ */
/* $NetBSD: activate.c,v 1.5 1995/04/23 10:33:18 cgd Exp $ */
/*
@@ -129,7 +129,7 @@ send_reply(int so, int fd, int error)
*/
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;
diff --git a/sbin/pflogd/privsep_fdpass.c b/sbin/pflogd/privsep_fdpass.c
index 0f310f8c2dc..0e6c3c4c1e8 100644
--- a/sbin/pflogd/privsep_fdpass.c
+++ b/sbin/pflogd/privsep_fdpass.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: privsep_fdpass.c,v 1.4 2008/03/15 16:19:02 deraadt Exp $ */
+/* $OpenBSD: privsep_fdpass.c,v 1.5 2008/03/24 16:11:08 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", __func__);
diff --git a/sbin/ping6/ping6.c b/sbin/ping6/ping6.c
index c2a6fc10ebc..179c294b255 100644
--- a/sbin/ping6/ping6.c
+++ b/sbin/ping6/ping6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ping6.c,v 1.72 2008/03/15 16:10:11 kettenis Exp $ */
+/* $OpenBSD: ping6.c,v 1.73 2008/03/24 16:11:08 deraadt Exp $ */
/* $KAME: ping6.c,v 1.163 2002/10/25 02:19:06 itojun Exp $ */
/*
@@ -264,7 +264,7 @@ main(int argc, char *argv[])
int ch, hold, packlen, preload, optval, ret_ga;
u_char *datap, *packet;
char *e, *target, *ifname = NULL, *gateway = NULL;
- int ip6optlen = 0, ip6optspace = 0;
+ int ip6optlen = 0;
struct cmsghdr *scmsgp = NULL;
#if defined(SO_SNDBUF) && defined(SO_RCVBUF)
u_long lsockbufsize;
@@ -498,8 +498,7 @@ main(int argc, char *argv[])
errx(1, "too many intermediate hops");
/*NOTREACHED*/
}
- ip6optlen = ip6optspace + CMSG_LEN(rthlen);
- ip6optspace += CMSG_SPACE(rthlen);
+ ip6optlen += CMSG_SPACE(rthlen);
}
if (options & F_NIGROUP) {
@@ -680,26 +679,20 @@ main(int argc, char *argv[])
*/
/* Specify the outgoing interface and/or the source address */
- if (usepktinfo) {
- ip6optlen = ip6optspace + CMSG_LEN(sizeof(struct in6_pktinfo));
- ip6optspace += CMSG_SPACE(sizeof(struct in6_pktinfo));
- }
+ if (usepktinfo)
+ ip6optlen += CMSG_SPACE(sizeof(struct in6_pktinfo));
- if (hoplimit != -1) {
- ip6optlen = ip6optspace + CMSG_LEN(sizeof(int));
- ip6optspace += CMSG_SPACE(sizeof(int));
- }
+ if (hoplimit != -1)
+ ip6optlen += CMSG_SPACE(sizeof(int));
#ifdef IPV6_REACHCONF
- if (options & F_REACHCONF) {
- ip6optlen = ip6optspace + CMSG_LEN(0);
- ip6optspace += CMSG_SPACE(0);
- }
+ if (options & F_REACHCONF)
+ ip6optlen += CMSG_SPACE(0);
#endif
/* set IP6 packet options */
if (ip6optlen) {
- if ((scmsg = malloc(ip6optspace)) == 0)
+ if ((scmsg = malloc(ip6optlen)) == 0)
errx(1, "can't allocate enough memory");
smsghdr.msg_control = (caddr_t)scmsg;
smsghdr.msg_controllen = ip6optlen;
@@ -929,7 +922,7 @@ main(int argc, char *argv[])
m.msg_iov = iov;
m.msg_iovlen = 1;
m.msg_control = (caddr_t)&cmsgbuf.buf;
- m.msg_controllen = CMSG_LEN(1024);
+ m.msg_controllen = sizeof(cmsgbuf.buf);
cc = recvmsg(s, &m, 0);
if (cc < 0) {
diff --git a/share/man/man3/CMSG_DATA.3 b/share/man/man3/CMSG_DATA.3
index 28e5b498ad2..1beb705b425 100644
--- a/share/man/man3/CMSG_DATA.3
+++ b/share/man/man3/CMSG_DATA.3
@@ -1,7 +1,7 @@
-.\" $OpenBSD: CMSG_DATA.3,v 1.4 2008/03/15 16:27:48 deraadt Exp $
+.\" $OpenBSD: CMSG_DATA.3,v 1.5 2008/03/24 16:11:07 deraadt Exp $
.\" Written by Jared Yanovich <jaredy@openbsd.org>
.\" Public domain, July 3, 2005
-.Dd $Mdocdate: March 15 2008 $
+.Dd $Mdocdate: March 24 2008 $
.Dt CMSG_DATA 3
.Os
.Sh NAME
@@ -61,10 +61,9 @@ This routine determines the size in bytes of a control message,
which includes the control message header.
.Fa len
specifies the length of the data held by the control message.
-This value is what is normally stored in
+This value is what is normally stored in the
.Fa cmsg_len
-and
-.Fa msg_msgcontrollen .
+of each control message.
This routine accounts for any alignment constraints on the beginning of
ancillary data.
.It Fn CMSG_NXTHDR mhdr cmsg
@@ -99,7 +98,7 @@ union {
memset(&msg, 0, sizeof(msg));
msg.msg_control = &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));
@@ -122,7 +121,7 @@ union {
memset(&msg, 0, sizeof(msg));
msg.msg_control = &cmsgbuf.buf;
-msg.msg_controllen = CMSG_LEN(sizeof(int));
+msg.msg_controllen = sizeof(cmsgbuf.buf);
if (recvmsg(s, &msg, 0) == -1)
err(1, "recvmsg");
diff --git a/usr.bin/ssh/monitor_fdpass.c b/usr.bin/ssh/monitor_fdpass.c
index 24cd59800db..ea6def12f4e 100644
--- a/usr.bin/ssh/monitor_fdpass.c
+++ b/usr.bin/ssh/monitor_fdpass.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: monitor_fdpass.c,v 1.16 2008/03/15 16:19:02 deraadt Exp $ */
+/* $OpenBSD: monitor_fdpass.c,v 1.17 2008/03/24 16:11:07 deraadt Exp $ */
/*
* Copyright 2001 Niels Provos <provos@citi.umich.edu>
* All rights reserved.
@@ -50,7 +50,7 @@ mm_send_fd(int sock, int fd)
memset(&msg, 0, sizeof(msg));
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;
@@ -96,7 +96,7 @@ mm_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) {
error("%s: recvmsg: %s", __func__, strerror(errno));
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);
}