Skip to content

Commit bf85a1a

Browse files
committed
Add note on zero-initialization and CMSG_NXTHDR.
1 parent 327cb39 commit bf85a1a

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

library/std/src/os/unix/net/ancillary.rs

+3
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,9 @@ impl<'a> SocketAncillary<'a> {
464464
/// All data written to the buffer must be valid ancillary data for the target platform,
465465
/// and you must call [`set_len()`](Self::set_len) after changing
466466
/// the buffer contents to update the internal bookkeeping.
467+
///
468+
/// Make sure to zero-initialize the buffer if you are going to use it with [`libc::CMSG_NXTHDR()`].
469+
/// That function requires the buffer to be zero-initialized in order to work correctly
467470
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
468471
pub unsafe fn buffer_mut(&mut self) -> &mut [MaybeUninit<u8>] {
469472
self.buffer

0 commit comments

Comments
 (0)