Skip to content

Commit

Permalink
elf: cap the number of allowed program headers (#461)
Browse files Browse the repository at this point in the history
  • Loading branch information
alessandrod authored Apr 27, 2023
1 parent 2643a04 commit e9c2d20
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,15 @@ impl<V: Verifier, C: ContextObject> Executable<V, C> {
{
return Err(ElfError::InvalidProgramHeader);
}

// The toolchain currently emits up to 4 program headers. 10 is a
// future proof nice round number.
//
// program_headers() returns an ExactSizeIterator so count doesn't
// actually iterate again.
if elf.program_headers().count() >= 10 {
return Err(ElfError::InvalidProgramHeader);
}
}

let num_text_sections = elf
Expand Down

0 comments on commit e9c2d20

Please sign in to comment.