Skip to content

Commit

Permalink
Fix size check for section headers
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-auer authored and m4b committed Jan 19, 2021
1 parent 3500b7a commit 84062ff
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/elf/section_header.rs
Expand Up @@ -473,8 +473,8 @@ if_alloc! {
self.sh_name, self.sh_offset, self.sh_size, overflow);
return Err(error::Error::Malformed(message));
}
let (end, overflow) = self.sh_addr.overflowing_add(self.sh_size);
if overflow || end > size as u64 {
let (_, overflow) = self.sh_addr.overflowing_add(self.sh_size);
if overflow {
let message = format!("Section {} size ({}) + addr ({}) is out of bounds. Overflowed: {}",
self.sh_name, self.sh_addr, self.sh_size, overflow);
return Err(error::Error::Malformed(message));
Expand Down

0 comments on commit 84062ff

Please sign in to comment.