summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Zoeller <rtzoeller@rtzoeller.com>2022-01-23 13:20:19 -0600
committerRyan Zoeller <rtzoeller@rtzoeller.com>2022-01-23 13:26:32 -0600
commitad7e3c719ce43e0210e71763109c42383ee5aa33 (patch)
tree64525d922a82c0f401ef527970e87b292d137851
parent8ee93662e78b029c0d55a5b67f8944fb1bedcc21 (diff)
downloadnix-ad7e3c719ce43e0210e71763109c42383ee5aa33.zip
InetAddr::from_std should set sin_len/sin6_len on the BSDs
-rw-r--r--CHANGELOG.md4
-rw-r--r--src/sys/socket/addr.rs10
2 files changed, 14 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 523bf304..39bceab7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -47,6 +47,10 @@ This project adheres to [Semantic Versioning](https://semver.org/).
(#[1639](https://github.com/nix-rust/nix/pull/1639))
### Fixed
+
+- `InetAddr::from_std` now sets the `sin_len`/`sin6_len` fields on the BSDs.
+ (#[1642](https://github.com/nix-rust/nix/pull/1642))
+
### Removed
- Removed public access to the inner fields of `NetlinkAddr`, `AlgAddr`,
diff --git a/src/sys/socket/addr.rs b/src/sys/socket/addr.rs
index 67e5d6c6..4517c548 100644
--- a/src/sys/socket/addr.rs
+++ b/src/sys/socket/addr.rs
@@ -330,6 +330,11 @@ impl InetAddr {
match *std {
net::SocketAddr::V4(ref addr) => {
InetAddr::V4(libc::sockaddr_in {
+ #[cfg(any(target_os = "dragonfly", target_os = "freebsd",
+ target_os = "haiku", target_os = "hermit",
+ target_os = "ios", target_os = "macos",
+ target_os = "netbsd", target_os = "openbsd"))]
+ sin_len: mem::size_of::<libc::sockaddr_in>() as u8,
sin_family: AddressFamily::Inet as sa_family_t,
sin_port: addr.port().to_be(), // network byte order
sin_addr: Ipv4Addr::from_std(addr.ip()).0,
@@ -338,6 +343,11 @@ impl InetAddr {
}
net::SocketAddr::V6(ref addr) => {
InetAddr::V6(libc::sockaddr_in6 {
+ #[cfg(any(target_os = "dragonfly", target_os = "freebsd",
+ target_os = "haiku", target_os = "hermit",
+ target_os = "ios", target_os = "macos",
+ target_os = "netbsd", target_os = "openbsd"))]
+ sin6_len: mem::size_of::<libc::sockaddr_in6>() as u8,
sin6_family: AddressFamily::Inet6 as sa_family_t,
sin6_port: addr.port().to_be(), // network byte order
sin6_addr: Ipv6Addr::from_std(addr.ip()).0,