Skip to content

Commit

Permalink
Fixed reading PE section data for contiguous sections (#354)
Browse files Browse the repository at this point in the history
Usually, sections are padded, but when they're not, a bug prevented accesses to the first byte of some sections
  • Loading branch information
daladim authored Aug 17, 2021
1 parent 0b76070 commit 054bf90
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/read/pe/section.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,12 @@ impl pe::ImageSectionHeader {
let section_va = self.virtual_address.get(LE);
let offset = va.checked_sub(section_va)?;
let section_data = self.pe_data(data).ok()?;
section_data.get(offset as usize..)
if (offset as usize) < section_data.len() {
section_data.get(offset as usize..)
} else {
// We're calling `.get(i..)` with a range. In case i == section_data.len(), this will return Some([]), not None
None
}
}
}

Expand Down

0 comments on commit 054bf90

Please sign in to comment.