summaryrefslogtreecommitdiff
path: root/regress/sys
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2008-03-13 01:49:54 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2008-03-13 01:49:54 +0000
commitf806a02a48dffd4879055cd8cdc1895a0a6c926e (patch)
tree6c61227927ac37c4d373490dda12a0ed461491c8 /regress/sys
parent2d29c72143d0f8408606ffb11045f029da0762f6 (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 'regress/sys')
-rw-r--r--regress/sys/kern/unfdpass/unfdpass.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/regress/sys/kern/unfdpass/unfdpass.c b/regress/sys/kern/unfdpass/unfdpass.c
index 75bb0b3fa00..b695b227446 100644
--- a/regress/sys/kern/unfdpass/unfdpass.c
+++ b/regress/sys/kern/unfdpass/unfdpass.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: unfdpass.c,v 1.12 2004/08/30 18:13:14 millert Exp $ */
+/* $OpenBSD: unfdpass.c,v 1.13 2008/03/13 01:49:53 deraadt Exp $ */
/* $NetBSD: unfdpass.c,v 1.3 1998/06/24 23:51:30 thorpej Exp $ */
/*-
@@ -74,7 +74,10 @@ main(int argc, char *argv[])
struct sockaddr_un sun, csun;
int csunlen;
pid_t pid;
- char message[CMSG_SPACE(sizeof(int) * 2)];
+ union {
+ struct cmsghdr hdr;
+ char buf[CMSG_SPACE(sizeof(int) * 2)];
+ } cmsgbuf;
int pflag;
extern char *__progname;
@@ -169,8 +172,8 @@ main(int argc, char *argv[])
* Grab the descriptors passed to us.
*/
(void) memset(&msg, 0, sizeof(msg));
- msg.msg_control = message;
- msg.msg_controllen = CMSG_LEN(sizeof(int) * 2);
+ msg.msg_control = &cmsgbuf.buf;
+ msg.msg_controllen = sizeof(cmsgbuf.buf);
if (recvmsg(sock, &msg, 0) < 0)
err(1, "recvmsg");
@@ -243,7 +246,10 @@ child(int sock)
struct cmsghdr *cmp;
int i, fd;
struct sockaddr_un sun;
- char cmsgbuf[CMSG_SPACE(sizeof(int) * 2)];
+ union {
+ struct cmsghdr hdr;
+ char buf[CMSG_SPACE(sizeof(int) * 2)];
+ } cmsgbuf;
int *files;
/*
@@ -263,8 +269,8 @@ child(int sock)
}
(void) memset(&msg, 0, sizeof(msg));
- msg.msg_control = cmsgbuf;
- msg.msg_controllen = CMSG_LEN(sizeof(int) * 2);
+ msg.msg_control = &cmsgbuf.buf;
+ msg.msg_controllen = sizeof(cmsgbuf.buf);
cmp = CMSG_FIRSTHDR(&msg);
cmp->cmsg_len = CMSG_LEN(sizeof(int) * 2);