summaryrefslogtreecommitdiff
path: root/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 /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 'sbin')
-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
4 files changed, 19 insertions, 26 deletions
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) {