Merge pull request #1234 from lifupan/2.0-dev-fix-read

rustjail: fix the issue of sync read
This commit is contained in:
Peng Tao 2021-01-08 14:03:46 +08:00 committed by GitHub
commit 855fe10bfd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -72,7 +72,15 @@ fn read_count(fd: RawFd, count: usize) -> Result<Vec<u8>> {
}
}
Ok(v[0..len].to_vec())
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>> {