Skip to content

Commit

Permalink
core: fix cmsg buffer lifetime
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxVerevkin committed Sep 16, 2024
1 parent d09fd12 commit ef0f8b0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion wayrs-core/src/transport/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ impl Transport for UnixStream {
flags |= libc::MSG_DONTWAIT;
}

let mut cmsg = [0u8; cmsg_space(std::mem::size_of::<[OwnedFd; FDS_OUT_LEN]>())];

let mhdr = {
let mut mhdr = unsafe { std::mem::zeroed::<libc::msghdr>() };
mhdr.msg_iov = bytes.as_ptr().cast_mut().cast();
mhdr.msg_iovlen = bytes.len() as _;

if !fds.is_empty() {
let fds_size = std::mem::size_of_val(fds);
let mut cmsg = [0u8; cmsg_space(std::mem::size_of::<[OwnedFd; FDS_OUT_LEN]>())];
let controllen = cmsg_space(fds_size);
assert!(controllen <= cmsg.len());

Expand Down

0 comments on commit ef0f8b0

Please sign in to comment.