feat(specctra-core-fuzz): add another fuzz target (for 'Structure')

This commit is contained in:
Alain Emilia Anna Zscheile 2024-12-05 20:32:26 +01:00
parent c1101b4304
commit acab24d7d4
3 changed files with 27 additions and 1 deletions

View File

@ -19,3 +19,10 @@ path = "fuzz_targets/fuzz_target_1.rs"
test = false
doc = false
bench = false
[[bin]]
name = "fuzz_target_2"
path = "fuzz_targets/fuzz_target_2.rs"
test = false
doc = false
bench = false

View File

@ -3,7 +3,7 @@
use libfuzzer_sys::fuzz_target;
fuzz_target!(|data: &str| {
let mut cursor = std::io::Cursor::new(data);
let cursor = std::io::Cursor::new(data);
use specctra_core::{read::ListTokenizer, structure::DsnFile};

View File

@ -0,0 +1,19 @@
#![no_main]
use libfuzzer_sys::fuzz_target;
fuzz_target!(|data: &str| {
let cursor = std::io::Cursor::new(data);
use specctra_core::{read::ListTokenizer, write::ListWriter, structure::Structure};
let mut tkz = ListTokenizer::new(cursor);
let res: Result<_, _> = tkz.read_value::<Structure>();
if let Ok(val) = res {
let mut dat = Vec::new();
let mut lw = ListWriter::new(&mut dat);
let _ = lw.write_value(&val);
}
});