mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-01-03 11:25: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;
|
const MIN_COMMAND_LEN: usize = 10;
|
||||||
|
|
||||||
// Bring in the minimum number of bytes that we should be able to read.
|
// Bring in the minimum number of bytes that we should be able to read.
|
||||||
if command.len < MIN_COMMAND_LEN {
|
stream
|
||||||
command.len += stream
|
.read_exact(&mut command.buf[command.len..MIN_COMMAND_LEN])
|
||||||
.read(&mut command.buf[command.len..MIN_COMMAND_LEN])
|
|
||||||
.map_err(Error::UnixRead)?;
|
.map_err(Error::UnixRead)?;
|
||||||
}
|
command.len = MIN_COMMAND_LEN;
|
||||||
|
|
||||||
// Now, finish reading the destination port number, by bringing in one byte at a time,
|
// 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
|
// until we reach an EOL terminator (or our buffer space runs out). Yeah, not
|
||||||
|
Loading…
Reference in New Issue
Block a user