Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/pe/relocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,16 +347,16 @@ impl<'a> RelocationData<'a> {
dd.virtual_address
))
})?;
// To allow parsing the rest, we will not raise a malformation error
// when we found that the base relocation directory not lies in the binary.
// If that's the case, we store an empty `bytes`, which implies no-op
// when `blocks` is called.
if bytes.len() < offset {
return Ok(Self { bytes: &[] });
}
let bytes = bytes[offset..]
.pread::<&[u8]>(dd.size as usize)
.map_err(|_| {
error::Error::Malformed(format!(
"base reloc offset {:#x} and size {:#x} exceeds the bounds of the bytes size {:#x}",
offset,
dd.size,
bytes.len()
))
})?;
.pread_with::<&[u8]>(0, dd.size as usize)
.unwrap_or_default();

Ok(Self { bytes })
}
Expand Down