From e80b5622ec956a92f24ce6487fb0d76e9c541515 Mon Sep 17 00:00:00 2001 From: iximeow Date: Wed, 12 Jan 2022 15:46:39 -0800 Subject: fuzz DisplayStyle::C and fix corresponding issues --- fuzz/Cargo.toml | 6 ++++++ fuzz/fuzz_targets/display_c_does_not_panic.rs | 21 +++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 fuzz/fuzz_targets/display_c_does_not_panic.rs (limited to 'fuzz') diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index 5c49296..53bcb81 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -26,3 +26,9 @@ name = "display_does_not_panic" path = "fuzz_targets/display_does_not_panic.rs" test = false doc = false + +[[bin]] +name = "display_c_does_not_panic" +path = "fuzz_targets/display_c_does_not_panic.rs" +test = false +doc = false diff --git a/fuzz/fuzz_targets/display_c_does_not_panic.rs b/fuzz/fuzz_targets/display_c_does_not_panic.rs new file mode 100644 index 0000000..129a560 --- /dev/null +++ b/fuzz/fuzz_targets/display_c_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) { + let _ = inst.display_with(yaxpeax_x86::long_mode::DisplayStyle::C).to_string(); + }; + + if let Ok(inst) = x86_32_decoder.decode_slice(data) { + let _ = inst.display_with(yaxpeax_x86::protected_mode::DisplayStyle::C).to_string(); + }; + + if let Ok(inst) = x86_16_decoder.decode_slice(data) { + let _ = inst.display_with(yaxpeax_x86::real_mode::DisplayStyle::C).to_string(); + }; +}); -- cgit v1.1