We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 764ff5d commit 075230dCopy full SHA for 075230d
src/sys/socket/sockopt.rs
@@ -1746,9 +1746,11 @@ impl<T: AsMut<[u8]>> Get<OsString> for GetOsString<T> {
1746
let len = self.len as usize;
1747
let mut v = unsafe { self.val.assume_init() };
1748
if let Ok(cs) = CStr::from_bytes_until_nul(&v.as_mut()[0..len]) {
1749
+ // It's legal for the kernel to return any number of NULs at the
1750
+ // end of the string. C applications don't care, after all.
1751
OsStr::from_bytes(cs.to_bytes())
1752
} else {
- // The OS returned a non-NUL-terminated string
1753
+ // Even zero NULs is possible.
1754
OsStr::from_bytes(&v.as_mut()[0..len])
1755
}
1756
.to_owned()
0 commit comments