summaryrefslogtreecommitdiff
path: root/fuzz/fuzz_targets
diff options
context:
space:
mode:
authoriximeow <me@iximeow.net>2023-12-23 13:20:53 -0800
committeriximeow <me@iximeow.net>2023-12-23 13:20:53 -0800
commit372d903e98953817c818211243fbc6f7e9294884 (patch)
tree02a20d66f5499f0d2aee5fd4fb031a8ac3461bb0 /fuzz/fuzz_targets
parentd7cc1c7c82a7995bdbdb67f791e378967f93f880 (diff)
add fuzz target for no panicking plz (it found panics)
Diffstat (limited to 'fuzz/fuzz_targets')
-rw-r--r--fuzz/fuzz_targets/no-panic.rs25
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");
+ }
+ }
+});