Skip to content

Commit 89c1510

Browse files
committed
fix idb_import invalid offset in EoF hit
1 parent cde1c38 commit 89c1510

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

plugins/idb_import/src/lib.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ struct BinaryViewReader<'a> {
8181
impl std::io::Read for BinaryViewReader<'_> {
8282
fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
8383
if !self.bv.offset_valid(self.offset) {
84-
return Err(std::io::Error::new(std::io::ErrorKind::UnexpectedEof, ""));
84+
return Ok(0);
8585
}
8686
let len = BinaryView::read(&self.bv, buf, self.offset);
8787
self.offset += u64::try_from(len).unwrap();
@@ -96,10 +96,17 @@ impl std::io::Seek for BinaryViewReader<'_> {
9696
std::io::SeekFrom::End(end) => self.bv.len().checked_add_signed(end),
9797
std::io::SeekFrom::Current(next) => self.offset.checked_add_signed(next),
9898
};
99-
let new_offset =
100-
new_offset.ok_or_else(|| std::io::Error::new(std::io::ErrorKind::UnexpectedEof, ""))?;
99+
let new_offset = new_offset.ok_or_else(|| {
100+
std::io::Error::new(
101+
std::io::ErrorKind::UnexpectedEof,
102+
"BinaryView offset overflow",
103+
)
104+
})?;
101105
if !self.bv.offset_valid(new_offset) {
102-
return Err(std::io::Error::new(std::io::ErrorKind::UnexpectedEof, ""));
106+
return Err(std::io::Error::new(
107+
std::io::ErrorKind::UnexpectedEof,
108+
"BinaryView Invalid offset",
109+
));
103110
}
104111
self.offset = new_offset;
105112
Ok(new_offset)

0 commit comments

Comments
 (0)