Skip to content

Commit 075230d

Browse files
committed
Fixup: expand the comment
1 parent 764ff5d commit 075230d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/sys/socket/sockopt.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1746,9 +1746,11 @@ impl<T: AsMut<[u8]>> Get<OsString> for GetOsString<T> {
17461746
let len = self.len as usize;
17471747
let mut v = unsafe { self.val.assume_init() };
17481748
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.
17491751
OsStr::from_bytes(cs.to_bytes())
17501752
} else {
1751-
// The OS returned a non-NUL-terminated string
1753+
// Even zero NULs is possible.
17521754
OsStr::from_bytes(&v.as_mut()[0..len])
17531755
}
17541756
.to_owned()

0 commit comments

Comments
 (0)