Simplify the notes fuzz target to just fuzz note parsing
The other ElfBytes logic is fuzzed elsewhere - this simplifies the fuzz target space to get more coverage of the notes parsing specifics.
This commit is contained in:
parent
a8c1125fa5
commit
ea3605ed29
@ -1,18 +1,17 @@
|
||||
#![no_main]
|
||||
|
||||
use elf::endian::AnyEndian;
|
||||
use elf::note::Note;
|
||||
use elf::ElfBytes;
|
||||
use elf::endian::NativeEndian;
|
||||
use elf::file::Class;
|
||||
use elf::note::{Note, NoteIterator};
|
||||
use libfuzzer_sys::fuzz_target;
|
||||
|
||||
fuzz_target!(|data: &[u8]| {
|
||||
if let Ok(file) = ElfBytes::<AnyEndian>::minimal_parse(data) {
|
||||
if let Some(shdrs) = file.section_headers() {
|
||||
if let Some(shdr) = shdrs.iter().find(|shdr| shdr.sh_type == elf::abi::SHT_NOTE) {
|
||||
if let Ok(notes) = file.section_data_as_notes(&shdr) {
|
||||
let _: Vec<Note> = notes.collect();
|
||||
}
|
||||
}
|
||||
}
|
||||
if data.is_empty() {
|
||||
return;
|
||||
}
|
||||
|
||||
let (head, tail) = data.split_at(1);
|
||||
|
||||
let iter = NoteIterator::new(NativeEndian, Class::ELF64, head[0] as usize, tail);
|
||||
let _: Vec<Note> = iter.collect();
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user