diff options
author | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2008-03-13 06:53:07 +0000 |
---|---|---|
committer | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2008-03-13 06:53:07 +0000 |
commit | f3a327fd9f35373ace53d05072f7cfb95a63248f (patch) | |
tree | 906471b07a6b1577752ea08d40a1ca11438b83e7 /app/xconsole/privsep.c | |
parent | fa800072668a4baef2124dff41fda25a91532fd6 (diff) |
Correct CMSG_SPACE and CMSG_LEN usage, same fixes as in the base system.
ok deraadt@
Diffstat (limited to 'app/xconsole/privsep.c')
-rw-r--r-- | app/xconsole/privsep.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/app/xconsole/privsep.c b/app/xconsole/privsep.c index 2fc1931a7..565b9fbbe 100644 --- a/app/xconsole/privsep.c +++ b/app/xconsole/privsep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: privsep.c,v 1.1 2006/11/26 16:59:50 matthieu Exp $ */ +/* $OpenBSD: privsep.c,v 1.2 2008/03/13 06:53:06 matthieu Exp $ */ /* * Copyright 2001 Niels Provos <provos@citi.umich.edu> * All rights reserved. @@ -63,7 +63,10 @@ static void send_fd(int socket, 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; @@ -72,8 +75,8 @@ send_fd(int socket, 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 = &cmsgbuf.buf; + msg.msg_controllen = sizeof(cmsgbuf.buf); cmsg = CMSG_FIRSTHDR(&msg); cmsg->cmsg_len = CMSG_LEN(sizeof(int)); cmsg->cmsg_level = SOL_SOCKET; @@ -99,7 +102,10 @@ static int receive_fd(int socket) { 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; @@ -111,8 +117,8 @@ receive_fd(int socket) 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(socket, &msg, 0)) == -1) warn("%s: recvmsg", __func__); |