diff --git a/library/std/src/sys/net/connection/socket/unix.rs b/library/std/src/sys/net/connection/socket/unix.rs index 5e20c0ffdfa6a..a2aeafbc23ef0 100644 --- a/library/std/src/sys/net/connection/socket/unix.rs +++ b/library/std/src/sys/net/connection/socket/unix.rs @@ -293,6 +293,11 @@ impl Socket { flags, ) })?; + + if ret == 0 && buf.capacity() == 0 { + return Err(io::const_error!(io::ErrorKind::InvalidInput, "0-byte buffer requested")); + } + unsafe { buf.advance_unchecked(ret as usize); }