diff options
Diffstat (limited to 'fuzz/fuzz_targets')
-rw-r--r-- | fuzz/fuzz_targets/decode_does_not_panic.rs | 6 | ||||
-rw-r--r-- | fuzz/fuzz_targets/displaysink_used_correctly.rs | 24 | ||||
-rw-r--r-- | fuzz/fuzz_targets/small_reg_is_always_old_bank_if_possible.rs | 4 |
3 files changed, 29 insertions, 5 deletions
diff --git a/fuzz/fuzz_targets/decode_does_not_panic.rs b/fuzz/fuzz_targets/decode_does_not_panic.rs index 5e6c15d..fd6efec 100644 --- a/fuzz/fuzz_targets/decode_does_not_panic.rs +++ b/fuzz/fuzz_targets/decode_does_not_panic.rs @@ -6,7 +6,7 @@ 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)); + x86_64_decoder.decode_slice(data).expect("is ok"); + x86_32_decoder.decode_slice(data).expect("is ok"); + x86_16_decoder.decode_slice(data).expect("is ok"); }); diff --git a/fuzz/fuzz_targets/displaysink_used_correctly.rs b/fuzz/fuzz_targets/displaysink_used_correctly.rs new file mode 100644 index 0000000..bd8d1db --- /dev/null +++ b/fuzz/fuzz_targets/displaysink_used_correctly.rs @@ -0,0 +1,24 @@ +#![no_main] +#[macro_use] extern crate libfuzzer_sys; +extern crate yaxpeax_x86; +extern crate yaxpeax_arch; + +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(); + + use yaxpeax_arch::testkit::DisplaySinkValidator; + + if let Ok(inst) = x86_64_decoder.decode_slice(data) { + inst.display_into(&mut DisplaySinkValidator::new()).expect("instruction can be displayed"); + }; + + if let Ok(inst) = x86_32_decoder.decode_slice(data) { + inst.display_into(&mut DisplaySinkValidator::new()).expect("instruction can be displayed"); + }; + + if let Ok(inst) = x86_16_decoder.decode_slice(data) { + inst.display_into(&mut DisplaySinkValidator::new()).expect("instruction can be displayed"); + }; +}); diff --git a/fuzz/fuzz_targets/small_reg_is_always_old_bank_if_possible.rs b/fuzz/fuzz_targets/small_reg_is_always_old_bank_if_possible.rs index a143205..b00ecb4 100644 --- a/fuzz/fuzz_targets/small_reg_is_always_old_bank_if_possible.rs +++ b/fuzz/fuzz_targets/small_reg_is_always_old_bank_if_possible.rs @@ -12,8 +12,8 @@ extern crate yaxpeax_x86; // cases. leaving them in for fuzz targets to match other cases, and In Case Of Future Change. 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(); + // 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) { for i in 0..inst.operand_count() { |