-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
OpenBSD fix long socket addresses #118349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -111,7 +111,17 @@ impl SocketAddr { | |
| // When there is a datagram from unnamed unix socket | ||
| // linux returns zero bytes of address | ||
| len = sun_path_offset(&addr) as libc::socklen_t; // i.e., zero-length address | ||
| } else if addr.sun_family != libc::AF_UNIX as libc::sa_family_t { | ||
| } else if cfg!(target_os = "openbsd") { | ||
| // OpenBSD implements getsockname in a way where the | ||
| // socket name's length is more than what the buffer | ||
| // actually contains. Figure out the length for ourselves. | ||
| // https://marc.info/?l=openbsd-bugs&m=170105481926736&w=2 | ||
| let sun_path: &[u8] = unsafe { crate::mem::transmute::<&[i8], &[u8]>(&addr.sun_path) }; | ||
| len = crate::sys::memchr::memchr(0, sun_path) | ||
| .map_or(len, |new_len| (new_len + sun_path_offset(&addr)) as libc::socklen_t); | ||
| } | ||
|
|
||
| if addr.sun_family != libc::AF_UNIX as libc::sa_family_t { | ||
|
||
| return Err(io::const_io_error!( | ||
| io::ErrorKind::InvalidInput, | ||
| "file descriptor did not correspond to a Unix socket", | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.