Skip to content

Commit 2b143ec

Browse files
committed
fix: never reply payload on error
On NBD_CMD_READ, never include any payload when replying with an error code.
1 parent 8c483b2 commit 2b143ec

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/device.rs

+2
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,9 @@ where
137137
.read(request.from, &mut reply_buf[nbd::SIZE_OF_REPLY..])
138138
.await
139139
{
140+
// On error we shall reply with error code but no payload.
140141
reply.error = err.raw_os_error().unwrap_or(nix::errno::Errno::EIO as i32);
142+
reply_buf.resize(nbd::SIZE_OF_REPLY, 0);
141143
}
142144
reply.write_to_slice(&mut reply_buf[..])?;
143145
}

0 commit comments

Comments
 (0)