summaryrefslogtreecommitdiff
path: root/src/sys
diff options
context:
space:
mode:
authorJustin Ossevoort <github@internetionals.nl>2021-03-02 17:34:29 +0100
committerJustin Ossevoort <justin.ossevoort@tesorion.nl>2021-03-05 14:18:29 +0100
commit5fc15828af43ba81246e40b0453350a296124d65 (patch)
tree9354bc32207b329ac5591a6d575f7e13c25343b6 /src/sys
parenta45d3e45fab3d216ecf0bfb2189b0e15fb2d8167 (diff)
downloadnix-5fc15828af43ba81246e40b0453350a296124d65.zip
Allow sockaddr_ll size mismatch
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.
Diffstat (limited to 'src/sys')
-rw-r--r--src/sys/socket/mod.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/sys/socket/mod.rs b/src/sys/socket/mod.rs
index 4db7ac6e..73f976b8 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::<sockaddr_ll>());
+ // 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::<sockaddr_ll>());
let sll = unsafe {
*(addr as *const _ as *const sockaddr_ll)
};