diff --git a/CHANGELOG.md b/CHANGELOG.md index 54b8935009..9636942d5f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,9 @@ This project adheres to [Semantic Versioning](http://semver.org/). (#[1390](https://github.com/nix-rust/nix/pull/1390)) ### Fixed +- Allow `sockaddr_ll` size, as reported by the Linux kernel, to be smaller then it's definition + (#[1395](https://github.com/nix-rust/nix/pull/1395)) + ### Removed - Removed `sys::socket::accept4` from Android arm because libc removed it in diff --git a/src/sys/socket/mod.rs b/src/sys/socket/mod.rs index 4db7ac6ef3..73f976b808 100644 --- a/src/sys/socket/mod.rs +++ b/src/sys/socket/mod.rs @@ -1711,7 +1711,10 @@ pub fn sockaddr_storage_to_addr( #[cfg(any(target_os = "android", target_os = "linux"))] libc::AF_PACKET => { use libc::sockaddr_ll; - assert_eq!(len as usize, mem::size_of::()); + // 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 + assert!(len as usize <= mem::size_of::()); let sll = unsafe { *(addr as *const _ as *const sockaddr_ll) };