diff options
Diffstat (limited to 'fuzz/fuzz_targets')
-rw-r--r-- | fuzz/fuzz_targets/no-panic.rs | 25 |
1 files changed, 25 insertions, 0 deletions
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"); + } + } +}); |