From 8332edeb582077739f86f898af5876386fbefc00 Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Sat, 15 Mar 2008 16:25:01 +0000 Subject: Repair more msg_controllen dealing with structures or arrays of descriptors; ok hshoexer, also looked at by kettenis and henning --- libexec/tftp-proxy/tftp-proxy.c | 4 ++-- libexec/tftpd/tftpd.c | 8 ++++---- usr.sbin/bgpd/imsg.c | 4 ++-- usr.sbin/ospf6d/packet.c | 4 ++-- usr.sbin/ospfd/packet.c | 4 ++-- usr.sbin/ppp/ppp/bundle.c | 6 +++--- usr.sbin/relayd/imsg.c | 4 ++-- usr.sbin/ripd/packet.c | 4 ++-- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/libexec/tftp-proxy/tftp-proxy.c b/libexec/tftp-proxy/tftp-proxy.c index 372731b1c3d..af1b35dbd69 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.3 2008/03/13 01:49:52 deraadt Exp $ +/* $OpenBSD: tftp-proxy.c,v 1.4 2008/03/15 16:25:00 deraadt Exp $ * * Copyright (c) 2005 DLS Internet Services * Copyright (c) 2004, 2005 Camiel Dobbelaar, @@ -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 = sizeof(cmsgbuf.buf); + msg.msg_controllen = CMSG_LEN(sizeof(struct sockaddr_storage)); if (recvmsg(fd, &msg, 0) < 0) { syslog(LOG_ERR, "recvmsg: %m"); diff --git a/libexec/tftpd/tftpd.c b/libexec/tftpd/tftpd.c index b22b3f48d60..0fe4c9c1535 100644 --- a/libexec/tftpd/tftpd.c +++ b/libexec/tftpd/tftpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tftpd.c,v 1.60 2008/03/13 01:49:52 deraadt Exp $ */ +/* $OpenBSD: tftpd.c,v 1.61 2008/03/15 16:25: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.60 2008/03/13 01:49:52 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: tftpd.c,v 1.61 2008/03/15 16:25: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 = sizeof(cmsgbuf.buf); + msg.msg_controllen = CMSG_LEN(sizeof(struct sockaddr_storage)); 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 = sizeof(cmsgbuf.buf); + msg.msg_controllen = CMSG_LEN(sizeof(struct sockaddr_storage)); i = recvmsg(fd, &msg, 0); if (i > 0) diff --git a/usr.sbin/bgpd/imsg.c b/usr.sbin/bgpd/imsg.c index a939876e637..c9b964507f7 100644 --- a/usr.sbin/bgpd/imsg.c +++ b/usr.sbin/bgpd/imsg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: imsg.c,v 1.40 2008/03/13 01:49:53 deraadt Exp $ */ +/* $OpenBSD: imsg.c,v 1.41 2008/03/15 16:25:00 deraadt Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -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 = sizeof(cmsgbuf.buf); + msg.msg_controllen = CMSG_LEN(sizeof(int) * 16); if ((n = recvmsg(ibuf->fd, &msg, 0)) == -1) { if (errno != EINTR && errno != EAGAIN) { diff --git a/usr.sbin/ospf6d/packet.c b/usr.sbin/ospf6d/packet.c index 96058ebfe52..d6d5e63edb9 100644 --- a/usr.sbin/ospf6d/packet.c +++ b/usr.sbin/ospf6d/packet.c @@ -1,4 +1,4 @@ -/* $OpenBSD: packet.c,v 1.7 2008/03/13 01:49:53 deraadt Exp $ */ +/* $OpenBSD: packet.c,v 1.8 2008/03/15 16:25:00 deraadt Exp $ */ /* * Copyright (c) 2004, 2005 Esben Norby @@ -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 = sizeof(cmsgbuf.buf); + msg.msg_controllen = CMSG_LEN(sizeof(struct in6_pktinfo)); 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 1f63836f7dc..d39e142db75 100644 --- a/usr.sbin/ospfd/packet.c +++ b/usr.sbin/ospfd/packet.c @@ -1,4 +1,4 @@ -/* $OpenBSD: packet.c,v 1.23 2008/03/13 01:49:53 deraadt Exp $ */ +/* $OpenBSD: packet.c,v 1.24 2008/03/15 16:25:00 deraadt Exp $ */ /* * Copyright (c) 2004, 2005 Esben Norby @@ -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 = sizeof(cmsgbuf.buf); + msg.msg_controllen = CMSG_LEN(sizeof(struct sockaddr_dl)); 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 17fad31be59..fd18a89d4ee 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.72 2008/03/13 01:49:53 deraadt Exp $ + * $OpenBSD: bundle.c,v 1.73 2008/03/15 16:25:00 deraadt Exp $ */ #include @@ -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 = sizeof cmsgbuf.buf; + msg.msg_controllen = CMSG_LEN(sizeof(int) * SEND_MAXFD); 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_SPACE(sizeof(int) * nfd); + msg.msg_controllen = CMSG_LEN(sizeof(int) * nfd); msg.msg_flags = 0; cmsg = CMSG_FIRSTHDR(&msg); cmsg->cmsg_len = msg.msg_controllen; diff --git a/usr.sbin/relayd/imsg.c b/usr.sbin/relayd/imsg.c index 5915b1fcdb3..d42dc9c252f 100644 --- a/usr.sbin/relayd/imsg.c +++ b/usr.sbin/relayd/imsg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: imsg.c,v 1.12 2008/03/13 01:49:53 deraadt Exp $ */ +/* $OpenBSD: imsg.c,v 1.13 2008/03/15 16:25:00 deraadt Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -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 = sizeof(cmsgbuf.buf); + msg.msg_controllen = CMSG_LEN(sizeof(int) * 16); 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 e314cbadeab..697abf93e69 100644 --- a/usr.sbin/ripd/packet.c +++ b/usr.sbin/ripd/packet.c @@ -1,4 +1,4 @@ -/* $OpenBSD: packet.c,v 1.8 2008/03/13 01:49:53 deraadt Exp $ */ +/* $OpenBSD: packet.c,v 1.9 2008/03/15 16:24:58 deraadt Exp $ */ /* * Copyright (c) 2006 Michele Marchetto @@ -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 = sizeof(&cmsgbuf.buf); + msg.msg_controllen = CMSG_LEN(sizeof(struct sockaddr_dl)); if ((r = recvmsg(fd, &msg, 0)) == -1) { if (errno != EINTR && errno != EAGAIN) -- cgit v1.2.3