mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-12-22 05:35:20 +00:00
virtio-devices: vsock: handle short read in muxer
Use read_exact to make sure we really get the minimum number of bytes. Fixes: #6621 Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
parent
2ffd5df018
commit
82ac114b8a
@ -495,11 +495,10 @@ impl VsockMuxer {
|
||||
const MIN_COMMAND_LEN: usize = 10;
|
||||
|
||||
// Bring in the minimum number of bytes that we should be able to read.
|
||||
if command.len < MIN_COMMAND_LEN {
|
||||
command.len += stream
|
||||
.read(&mut command.buf[command.len..MIN_COMMAND_LEN])
|
||||
.map_err(Error::UnixRead)?;
|
||||
}
|
||||
stream
|
||||
.read_exact(&mut command.buf[command.len..MIN_COMMAND_LEN])
|
||||
.map_err(Error::UnixRead)?;
|
||||
command.len = MIN_COMMAND_LEN;
|
||||
|
||||
// Now, finish reading the destination port number, by bringing in one byte at a time,
|
||||
// until we reach an EOL terminator (or our buffer space runs out). Yeah, not
|
||||
|
Loading…
Reference in New Issue
Block a user