mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-29 04:04:45 +00:00
rustjail: fix the issue of sync read
It should check the read count and return an error if read count didn't match the expected number. Fixes: #1233 Signed-off-by: fupan.lfp <fupan.lfp@antfin.com>
This commit is contained in:
parent
f531bab745
commit
0d3736d5c5
@ -72,7 +72,15 @@ fn read_count(fd: RawFd, count: usize) -> Result<Vec<u8>> {
|
||||
}
|
||||
}
|
||||
|
||||
if len != count {
|
||||
Err(anyhow::anyhow!(
|
||||
"invalid read count expect {} get {}",
|
||||
count,
|
||||
len
|
||||
))
|
||||
} else {
|
||||
Ok(v[0..len].to_vec())
|
||||
}
|
||||
}
|
||||
|
||||
pub fn read_sync(fd: RawFd) -> Result<Vec<u8>> {
|
||||
|
Loading…
Reference in New Issue
Block a user