Skip to content

Commit

Permalink
Use c_int type for SO_SNDBUF (#355)
Browse files Browse the repository at this point in the history
This is defined by POSIX as an 'int'.  Using a usize causes an invalid
value to be read on 64-bit big endian platforms.

Signed-off-by: A. Wilcox <AWilcox@Wilcox-Tech.com>
  • Loading branch information
awilfox committed Aug 24, 2024
1 parent ccf2aad commit e63bd8d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/platform/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ impl OsIpcSender {
/// Some of it is reserved by the kernel for bookkeeping.
fn get_system_sendbuf_size(&self) -> Result<usize, UnixError> {
unsafe {
let mut socket_sendbuf_size: usize = 0;
let mut socket_sendbuf_size_len = mem::size_of::<usize>() as socklen_t;
let mut socket_sendbuf_size: c_int = 0;
let mut socket_sendbuf_size_len = mem::size_of::<c_int>() as socklen_t;
if getsockopt(
self.fd.0,
libc::SOL_SOCKET,
Expand All @@ -225,7 +225,7 @@ impl OsIpcSender {
{
return Err(UnixError::last());
}
Ok(socket_sendbuf_size)
Ok(socket_sendbuf_size.try_into().unwrap())
}
}

Expand Down

0 comments on commit e63bd8d

Please sign in to comment.