diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2017-04-03 19:40:44 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2017-04-03 19:40:44 +0000 |
commit | 8a49ee144a773180935ca993fc30fa63e028a515 (patch) | |
tree | d9266d81889810fe5b26893d36aca4c4d0861a24 | |
parent | 58dacd7a66b4c86a95a0b56e69cc14d6e1a51567 (diff) |
Send and receive 1 byte of data in addition to the control message. This is
needed to make the code work in more cases.
Sending actually is not really needed, but do it anyway, to avoid confusing
mismatch between producer and consumer.
Problem noted by Luke Small; ok deraadt@
-rw-r--r-- | share/man/man3/CMSG_DATA.3 | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/share/man/man3/CMSG_DATA.3 b/share/man/man3/CMSG_DATA.3 index 1beb705b425..309be7ff810 100644 --- a/share/man/man3/CMSG_DATA.3 +++ b/share/man/man3/CMSG_DATA.3 @@ -1,7 +1,7 @@ -.\" $OpenBSD: CMSG_DATA.3,v 1.5 2008/03/24 16:11:07 deraadt Exp $ +.\" $OpenBSD: CMSG_DATA.3,v 1.6 2017/04/03 19:40:43 otto Exp $ .\" Written by Jared Yanovich <jaredy@openbsd.org> .\" Public domain, July 3, 2005 -.Dd $Mdocdate: March 24 2008 $ +.Dd $Mdocdate: April 3 2017 $ .Dt CMSG_DATA 3 .Os .Sh NAME @@ -95,10 +95,16 @@ union { struct cmsghdr hdr; unsigned char buf[CMSG_SPACE(sizeof(int))]; } cmsgbuf; +struct iovec io_vector[1]; + +io_vector[0].iov_base = &ch; +io_vector[0].iov_len = 1; memset(&msg, 0, sizeof(msg)); msg.msg_control = &cmsgbuf.buf; msg.msg_controllen = sizeof(cmsgbuf.buf); +msg.msg_iov = io_vector; +msg.msg_iovlen = 1; cmsg = CMSG_FIRSTHDR(&msg); cmsg->cmsg_len = CMSG_LEN(sizeof(int)); @@ -118,10 +124,16 @@ union { struct cmsghdr hdr; unsigned char buf[CMSG_SPACE(sizeof(int))]; } cmsgbuf; +struct iovec io_vector[1]; + +io_vector[0].iov_base = &ch; +io_vector[0].iov_len = 1; memset(&msg, 0, sizeof(msg)); msg.msg_control = &cmsgbuf.buf; msg.msg_controllen = sizeof(cmsgbuf.buf); +msg.msg_iov = io_vector; +msg.msg_iovlen = 1; if (recvmsg(s, &msg, 0) == -1) err(1, "recvmsg"); |