Skip to content

Commit

Permalink
Add cmsghdr padding fields on musl (#340)
Browse files Browse the repository at this point in the history
otherwise, the cmsg_type ends up in the wrong place and
musl just sees 0, leading to EINVAL errors from sendmsg
  • Loading branch information
ptrcnull authored Jul 14, 2024
1 parent d8b7f32 commit 310b8e4
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/platform/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1246,9 +1246,22 @@ fn S_ISSOCK(mode: mode_t) -> bool {
(mode & S_IFMT) == S_IFSOCK
}

#[cfg(target_env = "gnu")]
#[repr(C)]
struct cmsghdr {
cmsg_len: MsgControlLen,
cmsg_level: c_int,
cmsg_type: c_int,
}

#[cfg(not(target_env = "gnu"))]
#[repr(C)]
struct cmsghdr {
#[cfg(target_endian = "big")]
__pad1: c_int,
cmsg_len: MsgControlLen,
#[cfg(target_endian = "little")]
__pad1: c_int,
cmsg_level: c_int,
cmsg_type: c_int,
}
Expand Down

0 comments on commit 310b8e4

Please sign in to comment.