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

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>> { pub fn read_sync(fd: RawFd) -> Result<Vec<u8>> {