Skip to content

Commit

Permalink
Allow padded fields in libc::msghdr.
Browse files Browse the repository at this point in the history
  • Loading branch information
dvc94ch committed Dec 3, 2020
1 parent 3f521d5 commit 1ad0e37
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/unix/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,14 @@ impl NetlinkSocket {
iov_base: buf.as_mut_ptr() as *mut _,
iov_len: buf.len() * size_of!(u64),
};
let mut msghdr = libc::msghdr {
msg_name: address.as_mut_ptr() as _,
msg_namelen: size_of!(libc::sockaddr_nl) as _,
msg_iov: &mut iovec,
msg_iovlen: 1,
msg_control: std::ptr::null_mut(),
msg_controllen: 0,
msg_flags: 0,
};
let mut msghdr: libc::msghdr = std::mem::zeroed();
msghdr.msg_name = address.as_mut_ptr() as _;
msghdr.msg_namelen = size_of!(libc::sockaddr_nl) as _;
msghdr.msg_iov = &mut iovec;
msghdr.msg_iovlen = 1;
msghdr.msg_control = std::ptr::null_mut();
msghdr.msg_controllen = 0;
msghdr.msg_flags = 0;

let flags = libc::MSG_TRUNC | libc::MSG_CMSG_CLOEXEC;
let status = errno!(libc::recvmsg(fd.as_raw_fd(), &mut msghdr, flags))?;
Expand Down

0 comments on commit 1ad0e37

Please sign in to comment.