Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
elf: Fix arithmetic debug assertions (#260)
* elf: mitigate debug assertions by handling INT_MAX edge cases * add elf-specific fuzz harness
- Loading branch information
1 parent
578c790
commit 48f6ad9
Showing
3 changed files
with
32 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#![no_main] | ||
use libfuzzer_sys::fuzz_target; | ||
|
||
fuzz_target!(|data: &[u8]| { | ||
if let Ok(elf) = goblin::elf::Elf::parse(data) { | ||
for section_header in &elf.section_headers { | ||
let _ = elf.shdr_strtab.get(section_header.sh_name); | ||
} | ||
|
||
for _relocation in &elf.dynrels {} | ||
|
||
if let Some(mut it) = elf.iter_note_headers(data) { | ||
while let Some(Ok(_a)) = it.next() {} | ||
} | ||
|
||
if let Some(mut it) = elf.iter_note_sections(data, None) { | ||
while let Some(Ok(_a)) = it.next() {} | ||
} | ||
|
||
if let Some(mut it) = elf.iter_note_sections(data, Some("x")) { | ||
while let Some(Ok(_a)) = it.next() {} | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters