-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -110,7 +110,13 @@ where | |
pub fn sockaddr_to_addr(storage: &c::sockaddr_storage, len: usize) -> io::Result<SocketAddr> { | ||
match storage.ss_family as c_int { | ||
c::AF_INET => { | ||
#[cfg(not(target_os = "horizon"))] | ||
assert!(len >= mem::size_of::<c::sockaddr_in>()); | ||
|
||
// Under HorizonOS, sockaddr_in has 8 zeroed trailing bytes that do not get written. | ||
#[cfg(target_os = "horizon")] | ||
assert!(len >= (mem::size_of::<c::sockaddr_in>() - mem::size_of::<[c::c_char; 8]>())); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
Meziu
Author
Owner
|
||
|
||
Ok(SocketAddr::V4(FromInner::from_inner(unsafe { | ||
*(storage as *const _ as *const c::sockaddr_in) | ||
}))) | ||
|
@Meziu it seems like other targets also define
sin_zero
in libc e.g. https://github.com/rust-lang/libc/blob/72cb7aaf50bf70b5d360b1a64b0d52d3ed3fbf15/src/unix/linux_like/mod.rs#L45I wonder why they don't need to offset for padding the same way as this... is it possible that our definition of
sockaddr_storage
is actually the problematic one?