diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2008-03-13 01:49:54 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2008-03-13 01:49:54 +0000 |
commit | f806a02a48dffd4879055cd8cdc1895a0a6c926e (patch) | |
tree | 6c61227927ac37c4d373490dda12a0ed461491c8 /libexec | |
parent | 2d29c72143d0f8408606ffb11045f029da0762f6 (diff) |
Correct CMSG_SPACE and CMSG_LEN usage everywhere in the tree. Due to
an extensive discussion with otto, kettenis, millert, and hshoexer
Diffstat (limited to 'libexec')
-rw-r--r-- | libexec/ftpd/monitor_fdpass.c | 20 | ||||
-rw-r--r-- | libexec/login_skey/login_skey.c | 11 | ||||
-rw-r--r-- | libexec/login_tis/login_tis.c | 11 | ||||
-rw-r--r-- | libexec/tftp-proxy/tftp-proxy.c | 12 | ||||
-rw-r--r-- | libexec/tftpd/tftpd.c | 18 |
5 files changed, 44 insertions, 28 deletions
diff --git a/libexec/ftpd/monitor_fdpass.c b/libexec/ftpd/monitor_fdpass.c index 8047cd957c2..cc3d33d380d 100644 --- a/libexec/ftpd/monitor_fdpass.c +++ b/libexec/ftpd/monitor_fdpass.c @@ -1,4 +1,4 @@ -/* $OpenBSD: monitor_fdpass.c,v 1.1 2004/11/28 18:49:30 henning Exp $ */ +/* $OpenBSD: monitor_fdpass.c,v 1.2 2008/03/13 01:49:52 deraadt Exp $ */ /* * Copyright (c) 2002 Matthieu Herrb @@ -31,7 +31,10 @@ void send_fd(int sock, int fd) { struct msghdr msg; - char tmp[CMSG_SPACE(sizeof(int))]; + union { + struct cmsghdr hdr; + char buf[CMSG_SPACE(sizeof(int))]; + } cmsgbuf; struct cmsghdr *cmsg; struct iovec vec; int result = 0; @@ -40,8 +43,8 @@ send_fd(int sock, int fd) memset(&msg, 0, sizeof(msg)); if (fd >= 0) { - msg.msg_control = (caddr_t)tmp; - msg.msg_controllen = CMSG_LEN(sizeof(int)); + msg.msg_control = (caddr_t)&cmsgbuf.buf; + msg.msg_controllen = sizeof(cmsgbuf.buf); cmsg = CMSG_FIRSTHDR(&msg); cmsg->cmsg_len = CMSG_LEN(sizeof(int)); cmsg->cmsg_level = SOL_SOCKET; @@ -66,7 +69,10 @@ int recv_fd(int sock) { struct msghdr msg; - char tmp[CMSG_SPACE(sizeof(int))]; + union { + struct cmsghdr hdr; + char buf[CMSG_SPACE(sizeof(int))]; + } cmsgbuf; struct cmsghdr *cmsg; struct iovec vec; ssize_t n; @@ -78,8 +84,8 @@ recv_fd(int sock) vec.iov_len = sizeof(int); msg.msg_iov = &vec; msg.msg_iovlen = 1; - msg.msg_control = tmp; - msg.msg_controllen = sizeof(tmp); + msg.msg_control = &cmsgbuf.buf; + 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 0adea84540f..9a036c72e88 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.19 2007/07/26 17:48:41 millert Exp $ */ +/* $OpenBSD: login_skey.c,v 1.20 2008/03/13 01:49:52 deraadt Exp $ */ /* * Copyright (c) 2000, 2001, 2004 Todd C. Miller <Todd.Miller@courtesan.com> @@ -263,11 +263,14 @@ send_fd(int sock) { struct msghdr msg; struct cmsghdr *cmp; - char cmsgbuf[CMSG_SPACE(sizeof(int))]; + union { + struct cmsghdr hdr; + char buf[CMSG_SPACE(sizeof(int))]; + } cmsgbuf; memset(&msg, 0, sizeof(msg)); - msg.msg_control = cmsgbuf; - msg.msg_controllen = CMSG_LEN(sizeof(int)); + msg.msg_control = &cmsgbuf.buf; + 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 fafdb390ac0..ca436dd5897 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.6 2007/07/26 17:48:41 millert Exp $ */ +/* $OpenBSD: login_tis.c,v 1.7 2008/03/13 01:49:52 deraadt Exp $ */ /* * Copyright (c) 2004 Todd C. Miller <Todd.Miller@courtesan.com> @@ -289,11 +289,14 @@ send_fd(struct tis_connection *tc, int sock) { struct msghdr msg; struct cmsghdr *cmp; - char cmsgbuf[CMSG_SPACE(sizeof(int))]; + union { + struct cmsghdr hdr; + char buf[CMSG_SPACE(sizeof(int))]; + } cmsgbuf; memset(&msg, 0, sizeof(msg)); - msg.msg_control = cmsgbuf; - msg.msg_controllen = CMSG_LEN(sizeof(int)); + msg.msg_control = &cmsgbuf.buf; + 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 18d3323e911..372731b1c3d 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.2 2006/12/20 03:33:38 joel Exp $ +/* $OpenBSD: tftp-proxy.c,v 1.3 2008/03/13 01:49:52 deraadt Exp $ * * Copyright (c) 2005 DLS Internet Services * Copyright (c) 2004, 2005 Camiel Dobbelaar, <cd@sentia.nl> @@ -75,8 +75,10 @@ main(int argc, char *argv[]) char *p; struct tftphdr *tp; struct passwd *pw; - - char cbuf[CMSG_SPACE(sizeof(struct sockaddr_storage))]; + union { + struct cmsghdr hdr; + char buf[CMSG_SPACE(sizeof(struct sockaddr_storage))]; + } cmsgbuf; char req[PKTSIZE]; struct cmsghdr *cmsg; struct msghdr msg; @@ -161,8 +163,8 @@ main(int argc, char *argv[]) msg.msg_namelen = sizeof(from); msg.msg_iov = &iov; msg.msg_iovlen = 1; - msg.msg_control = cbuf; - msg.msg_controllen = CMSG_LEN(sizeof(struct sockaddr_storage)); + msg.msg_control = &cmsgbuf.buf; + 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 337e7123aed..b22b3f48d60 100644 --- a/libexec/tftpd/tftpd.c +++ b/libexec/tftpd/tftpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tftpd.c,v 1.59 2007/11/29 11:38:46 jmc Exp $ */ +/* $OpenBSD: tftpd.c,v 1.60 2008/03/13 01:49:52 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.59 2007/11/29 11:38:46 jmc Exp $"; +static char rcsid[] = "$OpenBSD: tftpd.c,v 1.60 2008/03/13 01:49:52 deraadt Exp $"; #endif /* not lint */ /* @@ -167,7 +167,10 @@ main(int argc, char *argv[]) int n = 0, on = 1, fd = 0, i, c, dobind = 1; struct tftphdr *tp; struct passwd *pw; - char cbuf[CMSG_SPACE(sizeof(struct sockaddr_storage))]; + union { + struct cmsghdr hdr; + char buf[CMSG_SPACE(sizeof(struct sockaddr_storage))]; + } cmsgbuf; struct cmsghdr *cmsg; struct msghdr msg; struct iovec iov; @@ -282,8 +285,8 @@ main(int argc, char *argv[]) msg.msg_namelen = sizeof(from); msg.msg_iov = &iov; msg.msg_iovlen = 1; - msg.msg_control = cbuf; - msg.msg_controllen = CMSG_LEN(sizeof(struct sockaddr_storage)); + msg.msg_control = &cmsgbuf.buf; + msg.msg_controllen = sizeof(cmsgbuf.buf); n = recvmsg(fd, &msg, 0); if (n < 0) { @@ -326,9 +329,8 @@ main(int argc, char *argv[]) msg.msg_namelen = sizeof(from); msg.msg_iov = &iov; msg.msg_iovlen = 1; - msg.msg_control = cbuf; - msg.msg_controllen = - CMSG_LEN(sizeof(struct sockaddr_storage)); + msg.msg_control = &cmsgbuf.buf; + msg.msg_controllen = sizeof(cmsgbuf.buf); i = recvmsg(fd, &msg, 0); if (i > 0) |