diff options
Diffstat (limited to 'src/sys/socket/mod.rs')
-rw-r--r-- | src/sys/socket/mod.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/sys/socket/mod.rs b/src/sys/socket/mod.rs index dcac2818..2ed38272 100644 --- a/src/sys/socket/mod.rs +++ b/src/sys/socket/mod.rs @@ -5,7 +5,7 @@ use cfg_if::cfg_if; use crate::{Result, errno::Errno}; use libc::{self, c_void, c_int, iovec, socklen_t, size_t, CMSG_FIRSTHDR, CMSG_NXTHDR, CMSG_DATA, CMSG_LEN}; -use memoffset::offset_of; +use std::convert::TryInto; use std::{mem, ptr, slice}; use std::os::unix::io::RawFd; #[cfg(target_os = "linux")] @@ -1934,10 +1934,10 @@ pub fn sockaddr_storage_to_addr( Ok(SockAddr::Inet(InetAddr::V6(sin6))) } libc::AF_UNIX => { - let pathlen = len - offset_of!(sockaddr_un, sun_path); unsafe { let sun = *(addr as *const _ as *const sockaddr_un); - Ok(SockAddr::Unix(UnixAddr::from_raw_parts(sun, pathlen))) + let sun_len = len.try_into().unwrap(); + Ok(SockAddr::Unix(UnixAddr::from_raw_parts(sun, sun_len))) } } #[cfg(any(target_os = "android", target_os = "linux"))] |