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]
|
#![no_main]
|
||||||
|
|
||||||
use elf::endian::AnyEndian;
|
use elf::endian::NativeEndian;
|
||||||
use elf::note::Note;
|
use elf::file::Class;
|
||||||
use elf::ElfBytes;
|
use elf::note::{Note, NoteIterator};
|
||||||
use libfuzzer_sys::fuzz_target;
|
use libfuzzer_sys::fuzz_target;
|
||||||
|
|
||||||
fuzz_target!(|data: &[u8]| {
|
fuzz_target!(|data: &[u8]| {
|
||||||
if let Ok(file) = ElfBytes::<AnyEndian>::minimal_parse(data) {
|
if data.is_empty() {
|
||||||
if let Some(shdrs) = file.section_headers() {
|
return;
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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