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:
fupan.lfp 2021-01-07 17:21:22 +08:00
parent f531bab745
commit 0d3736d5c5

View File

@ -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>> {