Skip to content

Commit 2d36e3a

Browse files
Merge #1395
1395: Allow sockaddr_ll size mismatch r=asomers a=internetionals Apparently the Linux kernel can return smaller sizes when the value in the last element of sockaddr_ll (`sll_addr`) is smaller than the declared size of that field. Co-authored-by: Justin Ossevoort <[email protected]>
2 parents a45d3e4 + 5fc1582 commit 2d36e3a

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
1111
(#[1390](https://github.com/nix-rust/nix/pull/1390))
1212

1313
### Fixed
14+
- Allow `sockaddr_ll` size, as reported by the Linux kernel, to be smaller then it's definition
15+
(#[1395](https://github.com/nix-rust/nix/pull/1395))
16+
1417
### Removed
1518

1619
- Removed `sys::socket::accept4` from Android arm because libc removed it in

src/sys/socket/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1711,7 +1711,10 @@ pub fn sockaddr_storage_to_addr(
17111711
#[cfg(any(target_os = "android", target_os = "linux"))]
17121712
libc::AF_PACKET => {
17131713
use libc::sockaddr_ll;
1714-
assert_eq!(len as usize, mem::size_of::<sockaddr_ll>());
1714+
// Apparently the Linux kernel can return smaller sizes when
1715+
// the value in the last element of sockaddr_ll (`sll_addr`) is
1716+
// smaller than the declared size of that field
1717+
assert!(len as usize <= mem::size_of::<sockaddr_ll>());
17151718
let sll = unsafe {
17161719
*(addr as *const _ as *const sockaddr_ll)
17171720
};

0 commit comments

Comments
 (0)