aboutsummaryrefslogtreecommitdiff
path: root/fuzz/fuzz_targets
diff options
context:
space:
mode:
authoriximeow <me@iximeow.net>2021-12-19 11:32:43 -0800
committeriximeow <me@iximeow.net>2021-12-19 11:32:43 -0800
commit26e019cc3788b6bac73969dc3d1753e883961339 (patch)
tree75ba2bc194df377412d31c7dbbe636ca8dee87fd /fuzz/fuzz_targets
parente7dec7baa9c6649d71e1b349d93dce6b0cd588bf (diff)
add in-tree cargo fuzz targets for decode and display impls
Diffstat (limited to 'fuzz/fuzz_targets')
-rw-r--r--fuzz/fuzz_targets/decode_does_not_panic.rs12
-rw-r--r--fuzz/fuzz_targets/display_does_not_panic.rs21
2 files changed, 33 insertions, 0 deletions
diff --git a/fuzz/fuzz_targets/decode_does_not_panic.rs b/fuzz/fuzz_targets/decode_does_not_panic.rs
new file mode 100644
index 0000000..5e6c15d
--- /dev/null
+++ b/fuzz/fuzz_targets/decode_does_not_panic.rs
@@ -0,0 +1,12 @@
+#![no_main]
+#[macro_use] extern crate libfuzzer_sys;
+extern crate yaxpeax_x86;
+
+fuzz_target!(|data: &[u8]| {
+ let x86_64_decoder = yaxpeax_x86::long_mode::InstDecoder::default();
+ let x86_32_decoder = yaxpeax_x86::protected_mode::InstDecoder::default();
+ let x86_16_decoder = yaxpeax_x86::real_mode::InstDecoder::default();
+ drop(x86_64_decoder.decode_slice(data));
+ drop(x86_32_decoder.decode_slice(data));
+ drop(x86_16_decoder.decode_slice(data));
+});
diff --git a/fuzz/fuzz_targets/display_does_not_panic.rs b/fuzz/fuzz_targets/display_does_not_panic.rs
new file mode 100644
index 0000000..97a14b8
--- /dev/null
+++ b/fuzz/fuzz_targets/display_does_not_panic.rs
@@ -0,0 +1,21 @@
+#![no_main]
+#[macro_use] extern crate libfuzzer_sys;
+extern crate yaxpeax_x86;
+
+fuzz_target!(|data: &[u8]| {
+ let x86_64_decoder = yaxpeax_x86::long_mode::InstDecoder::default();
+ let x86_32_decoder = yaxpeax_x86::protected_mode::InstDecoder::default();
+ let x86_16_decoder = yaxpeax_x86::real_mode::InstDecoder::default();
+
+ if let Ok(inst) = x86_64_decoder.decode_slice(data) {
+ inst.write_to(&mut String::new()).expect("format does not panic");
+ };
+
+ if let Ok(inst) = x86_32_decoder.decode_slice(data) {
+ inst.write_to(&mut String::new()).expect("format does not panic");
+ };
+
+ if let Ok(inst) = x86_16_decoder.decode_slice(data) {
+ inst.write_to(&mut String::new()).expect("format does not panic");
+ };
+});