From 372d903e98953817c818211243fbc6f7e9294884 Mon Sep 17 00:00:00 2001 From: iximeow Date: Sat, 23 Dec 2023 13:20:53 -0800 Subject: add fuzz target for no panicking plz (it found panics) --- fuzz/fuzz_targets/no-panic.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 fuzz/fuzz_targets/no-panic.rs (limited to 'fuzz/fuzz_targets') diff --git a/fuzz/fuzz_targets/no-panic.rs b/fuzz/fuzz_targets/no-panic.rs new file mode 100644 index 0000000..65efa6a --- /dev/null +++ b/fuzz/fuzz_targets/no-panic.rs @@ -0,0 +1,25 @@ +#![no_main] +use libfuzzer_sys::fuzz_target; + +use yaxpeax_arch::Decoder; + +use std::fmt::Write; + +fuzz_target!(|data: &[u8]| { + + let decoders = [ + yaxpeax_rx::InstDecoder::v1(), + yaxpeax_rx::InstDecoder::v2(), + yaxpeax_rx::InstDecoder::v3(), + ]; + + let mut rx_inst = yaxpeax_rx::Instruction::default(); + + for decoder in decoders { + let mut words = yaxpeax_arch::U8Reader::new(data); + // test decoding, may be ok or not, but should not panic + if let Ok(()) = decoder.decode_into(&mut rx_inst, &mut words) { + write!(&mut String::new(), "{}", rx_inst).expect("formatting does not panic either"); + } + } +}); -- cgit v1.1