diff options
author | Matthew Gregan <kinetik@flim.org> | 2017-06-20 15:30:48 +1200 |
---|---|---|
committer | Matthew Gregan <kinetik@flim.org> | 2017-07-10 13:04:33 +1200 |
commit | 64815c61836ece60d6d01d1a1ecfc1877d5bb866 (patch) | |
tree | 3bd134d4d6c26bfba9023c52a5789a9df19099e2 /src | |
parent | 2e00adf804f0ebacfe982063c0f98af836efd4f1 (diff) | |
download | nix-64815c61836ece60d6d01d1a1ecfc1877d5bb866.zip |
Fix sendmsg on macOS when passing a zero entry cmsgs array.
Diffstat (limited to 'src')
-rw-r--r-- | src/sys/socket/mod.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/sys/socket/mod.rs b/src/sys/socket/mod.rs index 88fe02fe..c11b5367 100644 --- a/src/sys/socket/mod.rs +++ b/src/sys/socket/mod.rs @@ -277,12 +277,18 @@ pub fn sendmsg<'a>(fd: RawFd, iov: &[IoVec<&'a [u8]>], cmsgs: &[ControlMessage<' None => (0 as *const _, 0), }; + let cmsg_ptr = if capacity > 0 { + cmsg_buffer.as_ptr() as *const c_void + } else { + ptr::null() + }; + let mhdr = msghdr { msg_name: name as *const c_void, msg_namelen: namelen, msg_iov: iov.as_ptr(), msg_iovlen: iov.len() as size_t, - msg_control: cmsg_buffer.as_ptr() as *const c_void, + msg_control: cmsg_ptr, msg_controllen: capacity as size_t, msg_flags: 0, }; |