Repair msg_controllen. In those cases it should just be

CMSG_SIZE(sizeof(int)), not sizeof(buffer) which may be larger because
of alignment. Based on fixes in base system.
This commit is contained in:
matthieu 2008-03-15 17:14:11 +00:00
parent 4756cae49c
commit 16236de311
2 changed files with 6 additions and 6 deletions

View File

@ -1,4 +1,4 @@
/* $OpenBSD: privsep.c,v 1.2 2008/03/13 06:53:06 matthieu Exp $ */
/* $OpenBSD: privsep.c,v 1.3 2008/03/15 17:14:11 matthieu Exp $ */
/*
* Copyright 2001 Niels Provos <provos@citi.umich.edu>
* All rights reserved.
@ -76,7 +76,7 @@ send_fd(int socket, int fd)
if (fd >= 0) {
msg.msg_control = &cmsgbuf.buf;
msg.msg_controllen = sizeof(cmsgbuf.buf);
msg.msg_controllen = CMSG_LEN(sizeof(int));
cmsg = CMSG_FIRSTHDR(&msg);
cmsg->cmsg_len = CMSG_LEN(sizeof(int));
cmsg->cmsg_level = SOL_SOCKET;
@ -118,7 +118,7 @@ receive_fd(int socket)
msg.msg_iov = &vec;
msg.msg_iovlen = 1;
msg.msg_control = &cmsgbuf.buf;
msg.msg_controllen = sizeof(cmsgbuf.buf);
msg.msg_controllen = CMSG_LEN(sizeof(int));
if ((n = recvmsg(socket, &msg, 0)) == -1)
warn("%s: recvmsg", __func__);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: privsep.c,v 1.3 2008/03/13 06:53:06 matthieu Exp $ */
/* $OpenBSD: privsep.c,v 1.4 2008/03/15 17:14:11 matthieu Exp $ */
/*
* Copyright 2001 Niels Provos <provos@citi.umich.edu>
* All rights reserved.
@ -148,7 +148,7 @@ send_fd(int socket, int fd)
if (fd >= 0) {
msg.msg_control = &cmsgbuf.buf;
msg.msg_controllen = sizeof(cmsgbuf.buf);
msg.msg_controllen = CMSG_LEN(sizeof(int));
cmsg = CMSG_FIRSTHDR(&msg);
cmsg->cmsg_len = CMSG_LEN(sizeof(int));
cmsg->cmsg_level = SOL_SOCKET;
@ -190,7 +190,7 @@ receive_fd(int socket)
msg.msg_iov = &vec;
msg.msg_iovlen = 1;
msg.msg_control = &cmsgbuf.buf;
msg.msg_controllen = sizeof(cmsgbuf.buf);
msg.msg_controllen = CMSG_LEN(sizeof(int));
if ((n = recvmsg(socket, &msg, 0)) == -1)
warn("%s: recvmsg", __func__);