aboutsummaryrefslogtreecommitdiff
path: root/fuzz
diff options
context:
space:
mode:
Diffstat (limited to 'fuzz')
-rw-r--r--fuzz/Cargo.toml8
-rw-r--r--fuzz/fuzz_targets/decode_does_not_panic.rs6
-rw-r--r--fuzz/fuzz_targets/displaysink_used_correctly.rs24
-rw-r--r--fuzz/fuzz_targets/small_reg_is_always_old_bank_if_possible.rs4
4 files changed, 37 insertions, 5 deletions
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() {