Skip to content

Commit

Permalink
Add validation for scoped slice bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
kkent030315 committed Oct 28, 2024
1 parent b4c2672 commit 96ae98f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/pe/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,13 @@ impl<'a> DebugData<'a> {
))
})?;

// Ensure that the offset and size do not exceed the length of the bytes slice
if offset + dd.size as usize > bytes.len() {
return Err(error::Error::Malformed(format!(
"ImageDebugDirectory offset {:#x} and size {:#x} exceeds the bounds of the bytes size {:#x}",
offset, dd.size, bytes.len()
)));
}
let data = &bytes[offset..offset + dd.size as usize];
let iterator = ImageDebugDirectoryIterator { data, rva_offset };

Expand Down

0 comments on commit 96ae98f

Please sign in to comment.