Skip to content

Commit

Permalink
Merge #1736
Browse files Browse the repository at this point in the history
1736: Fix socket address family checks r=rtzoeller a=qwandor

The `SockaddrLike::from_raw` implementations for `VsockAddr` and `SysControlAddr` were checking against the wrong address family constant. This PR makes them consistent with the values matched against in `SockaddrStorage::from_raw`.

Co-authored-by: Andrew Walbran <qwandor@google.com>
  • Loading branch information
bors[bot] and qwandor authored Jun 9, 2022
2 parents 32d597b + ccf1b80 commit b3ba2b5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ This project adheres to [Semantic Versioning](https://semver.org/).
- Enabled `SockaddrStorage::{as_link_addr, as_link_addr_mut}` for Linux-like
operating systems.
(#[1729](https://github.com/nix-rust/nix/pull/1729))
- Fixed `SockaddrLike::from_raw` implementations for `VsockAddr` and
`SysControlAddr`.
(#[1736](https://github.com/nix-rust/nix/pull/1736))

### Removed

Expand Down
4 changes: 2 additions & 2 deletions src/sys/socket/addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2259,7 +2259,7 @@ pub mod sys_control {
return None;
}
}
if (*addr).sa_family as i32 != libc::AF_INET6 as i32 {
if (*addr).sa_family as i32 != libc::AF_SYSTEM as i32 {
return None;
}
Some(SysControlAddr(*(addr as *const libc::sockaddr_ctl)))
Expand Down Expand Up @@ -2566,7 +2566,7 @@ pub mod vsock {
return None;
}
}
if (*addr).sa_family as i32 != libc::AF_INET6 as i32 {
if (*addr).sa_family as i32 != libc::AF_VSOCK as i32 {
return None;
}
Some(VsockAddr(*(addr as *const libc::sockaddr_vm)))
Expand Down

0 comments on commit b3ba2b5

Please sign in to comment.