Skip to content

Commit

Permalink
🚑️ zb: Handle 0 bytes received from socket
Browse files Browse the repository at this point in the history
Seems the assumpption that we can't ever get 0 bytes is wrong. Had this
in busd:

thread 'tokio-runtime-worker' panicked at 'assertion failed: read == 1', /home/zeenix/.cargo/git/checkouts/zbus-8f2422ba485129bc/662a6d1/zbus/src/handshake.rs:697:21
  • Loading branch information
zeenix committed Jun 21, 2023
1 parent 5260c76 commit 13e1150
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions zbus/src/raw/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ fn fd_recvmsg(fd: RawFd, buffer: &mut [u8]) -> io::Result<(usize, Vec<OwnedFd>)>

match recvmsg::<UnixAddr>(fd, &mut iov, Some(&mut cmsgspace), MsgFlags::empty()) {
Ok(msg) => {
if msg.bytes == 0 {
return Err(io::Error::new(
io::ErrorKind::UnexpectedEof,
"failed to read from buffer",
));
}
let mut fds = vec![];
for cmsg in msg.cmsgs() {
#[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
Expand Down

0 comments on commit 13e1150

Please sign in to comment.