From 238d65c98b2983f87c89f78a793ba7c56dcf7b01 Mon Sep 17 00:00:00 2001 From: iximeow Date: Sun, 23 Jun 2024 23:13:03 -0700 Subject: update yaxpeax-arch to 0.3.1, fix fuzz target warnings --- fuzz/Cargo.toml | 8 ++++++++ fuzz/fuzz_targets/decode_does_not_panic.rs | 6 +++--- fuzz/fuzz_targets/displaysink_used_correctly.rs | 24 ++++++++++++++++++++++ .../small_reg_is_always_old_bank_if_possible.rs | 4 ++-- 4 files changed, 37 insertions(+), 5 deletions(-) create mode 100644 fuzz/fuzz_targets/displaysink_used_correctly.rs (limited to 'fuzz') diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index 60690f6..2203dc3 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -10,6 +10,8 @@ cargo-fuzz = true [dependencies.yaxpeax-x86] path = ".." +[dependencies.yaxpeax-arch] +version = "0.3.1" [dependencies.libfuzzer-sys] git = "https://github.com/rust-fuzz/libfuzzer-sys.git" @@ -28,6 +30,12 @@ test = false doc = false [[bin]] +name = "displaysink_used_correctly" +path = "fuzz_targets/displaysink_used_correctly.rs" +test = false +doc = false + +[[bin]] name = "display_c_does_not_panic" path = "fuzz_targets/display_c_does_not_panic.rs" test = false 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() { -- cgit v1.1