Skip to content

Commit ae2b7b3

Browse files
bors[bot]rtzoeller
andauthored
Merge #1642
1642: InetAddr::from_std should set sin_len/sin6_len on the BSDs r=asomers a=rtzoeller Resolves #1246. Co-authored-by: Ryan Zoeller <[email protected]>
2 parents 4c3001b + ad7e3c7 commit ae2b7b3

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ This project adheres to [Semantic Versioning](https://semver.org/).
4747
(#[1639](https://github.com/nix-rust/nix/pull/1639))
4848

4949
### Fixed
50+
51+
- `InetAddr::from_std` now sets the `sin_len`/`sin6_len` fields on the BSDs.
52+
(#[1642](https://github.com/nix-rust/nix/pull/1642))
53+
5054
### Removed
5155

5256
- Removed public access to the inner fields of `NetlinkAddr`, `AlgAddr`,

src/sys/socket/addr.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,11 @@ impl InetAddr {
330330
match *std {
331331
net::SocketAddr::V4(ref addr) => {
332332
InetAddr::V4(libc::sockaddr_in {
333+
#[cfg(any(target_os = "dragonfly", target_os = "freebsd",
334+
target_os = "haiku", target_os = "hermit",
335+
target_os = "ios", target_os = "macos",
336+
target_os = "netbsd", target_os = "openbsd"))]
337+
sin_len: mem::size_of::<libc::sockaddr_in>() as u8,
333338
sin_family: AddressFamily::Inet as sa_family_t,
334339
sin_port: addr.port().to_be(), // network byte order
335340
sin_addr: Ipv4Addr::from_std(addr.ip()).0,
@@ -338,6 +343,11 @@ impl InetAddr {
338343
}
339344
net::SocketAddr::V6(ref addr) => {
340345
InetAddr::V6(libc::sockaddr_in6 {
346+
#[cfg(any(target_os = "dragonfly", target_os = "freebsd",
347+
target_os = "haiku", target_os = "hermit",
348+
target_os = "ios", target_os = "macos",
349+
target_os = "netbsd", target_os = "openbsd"))]
350+
sin6_len: mem::size_of::<libc::sockaddr_in6>() as u8,
341351
sin6_family: AddressFamily::Inet6 as sa_family_t,
342352
sin6_port: addr.port().to_be(), // network byte order
343353
sin6_addr: Ipv6Addr::from_std(addr.ip()).0,

0 commit comments

Comments
 (0)