From 302bc54bd0da0104b82ab9396271936159be09db Mon Sep 17 00:00:00 2001 From: Thomas de Zeeuw Date: Sun, 9 Jun 2024 14:48:24 +0200 Subject: [PATCH] Use mem::zeroed in UDS accept Matching what we do in the unix_addr function. --- src/sys/unix/uds/listener.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/sys/unix/uds/listener.rs b/src/sys/unix/uds/listener.rs index acbaeb1fb..fc58417d9 100644 --- a/src/sys/unix/uds/listener.rs +++ b/src/sys/unix/uds/listener.rs @@ -22,17 +22,15 @@ pub(crate) fn bind_addr(address: &SocketAddr) -> io::Result { } pub(crate) fn accept(listener: &net::UnixListener) -> io::Result<(UnixStream, SocketAddr)> { - let sockaddr = mem::MaybeUninit::::zeroed(); - - // This is safe to assume because a `libc::sockaddr_un` filled with `0` - // bytes is properly initialized. + // SAFETY: `libc::sockaddr_un` zero filled is properly initialized. // // `0` is a valid value for `sockaddr_un::sun_family`; it is // `libc::AF_UNSPEC`. // // `[0; 108]` is a valid value for `sockaddr_un::sun_path`; it begins an // abstract path. - let mut sockaddr = unsafe { sockaddr.assume_init() }; + let mut sockaddr = unsafe { mem::zeroed::() }; + let mut socklen = mem::size_of_val(&sockaddr) as libc::socklen_t; #[cfg(not(any(