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 --- Cargo.toml | 2 +- ffi/long_mode/Cargo.toml | 2 +- ffi/multiarch/Cargo.toml | 2 +- ffi/protected_mode/Cargo.toml | 2 +- ffi/real_mode/Cargo.toml | 2 +- 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 ++-- 9 files changed, 42 insertions(+), 10 deletions(-) create mode 100644 fuzz/fuzz_targets/displaysink_used_correctly.rs diff --git a/Cargo.toml b/Cargo.toml index ecc56be..907a70b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ readme = "README.md" edition = "2018" [dependencies] -yaxpeax-arch = { version = "0.2.7", default-features = false, features = [] } +yaxpeax-arch = { version = "0.3.1", default-features = false, features = [] } "num-traits" = { version = "0.2", default-features = false } "serde" = { version = "1.0", optional = true } "serde_json" = { version = "1.0", optional = true } diff --git a/ffi/long_mode/Cargo.toml b/ffi/long_mode/Cargo.toml index 2df8450..0b6a529 100644 --- a/ffi/long_mode/Cargo.toml +++ b/ffi/long_mode/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" [dependencies] yaxpeax-x86 = { path = "../../", default-features = false } -yaxpeax-arch = { version = "0.2.7", default-features = false } +yaxpeax-arch = { version = "0.3.1", default-features = false } [lib] name = "yaxpeax_x86_ffi_long_mode" diff --git a/ffi/multiarch/Cargo.toml b/ffi/multiarch/Cargo.toml index c15efbb..1e2cd2d 100644 --- a/ffi/multiarch/Cargo.toml +++ b/ffi/multiarch/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" [dependencies] yaxpeax-x86 = { path = "../../", default-features = false } -yaxpeax-arch = { version = "0.2.7", default-features = false } +yaxpeax-arch = { version = "0.3.1", default-features = false } [lib] name = "yaxpeax_x86_ffi_multiarch" diff --git a/ffi/protected_mode/Cargo.toml b/ffi/protected_mode/Cargo.toml index 711845e..ef99a39 100644 --- a/ffi/protected_mode/Cargo.toml +++ b/ffi/protected_mode/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" [dependencies] yaxpeax-x86 = { path = "../../", default-features = false } -yaxpeax-arch = { version = "0.2.7", default-features = false } +yaxpeax-arch = { version = "0.3.1", default-features = false } [lib] name = "yaxpeax_x86_ffi_protected_mode" diff --git a/ffi/real_mode/Cargo.toml b/ffi/real_mode/Cargo.toml index 689472e..c079e0e 100644 --- a/ffi/real_mode/Cargo.toml +++ b/ffi/real_mode/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" [dependencies] yaxpeax-x86 = { path = "../../", default-features = false } -yaxpeax-arch = { version = "0.2.7", default-features = false } +yaxpeax-arch = { version = "0.3.1", default-features = false } [lib] name = "yaxpeax_x86_ffi_real_mode" 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