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:
@@ -72,8 +72,16 @@ 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>> {
let buf = read_count(fd, MSG_SIZE)?;
