Skip to content

Commit

Permalink
Check malformed for iterator data
Browse files Browse the repository at this point in the history
  • Loading branch information
kkent030315 committed Nov 2, 2024
1 parent e0f95c1 commit 4c6712c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/pe/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,14 @@ impl<'a> ResourceData<'a> {
let count = image_resource_directory.count() as usize;
let offset = core::mem::size_of::<ImageResourceDirectory>();
let size = image_resource_directory.entries_size();
if offset + size as usize > data.len() {
return Err(error::Error::Malformed(format!(
"Resource entry offset ({:#x}) and size ({:#x}) exceeds data slice ({:#x})",
offset,
size,
data.len()
)));
}
let iterator_data = &data[offset..offset + size];
let iterator = ResourceEntryIterator {
num_resources: count,
Expand Down

0 comments on commit 4c6712c

Please sign in to comment.