From d02b0f8527b04cafcc465c411231c8892cb2b725 Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Thu, 15 Feb 2018 20:34:56 +0300 Subject: [PATCH] Add plain load to fuzzer (#58) --- fuzz/Cargo.toml | 4 ++++ fuzz/fuzz_targets/load.rs | 8 ++------ fuzz/fuzz_targets/load_wabt.rs | 13 +++++++++++++ 3 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 fuzz/fuzz_targets/load_wabt.rs diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index b5df657..52c3c5f 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -24,6 +24,10 @@ members = ["."] name = "load" path = "fuzz_targets/load.rs" +[[bin]] +name = "load_wabt" +path = "fuzz_targets/load_wabt.rs" + [[bin]] name = "load_wasmparser" path = "fuzz_targets/load_wasmparser.rs" diff --git a/fuzz/fuzz_targets/load.rs b/fuzz/fuzz_targets/load.rs index 0c98907..4df04ae 100644 --- a/fuzz/fuzz_targets/load.rs +++ b/fuzz/fuzz_targets/load.rs @@ -1,13 +1,9 @@ #![no_main] #[macro_use] extern crate libfuzzer_sys; -extern crate wabt; extern crate wasmi; fuzz_target!(|data: &[u8]| { - let wasmi_result = wasmi::Module::from_buffer(data); - let wabt_result = - wabt::Module::read_binary(data, &Default::default()).and_then(|m| m.validate()); - - assert_eq!(wasmi_result.is_ok(), wabt_result.is_ok()); + // Just check if loading some arbitrary buffer doesn't panic. + let _ = wasmi::Module::from_buffer(data); }); diff --git a/fuzz/fuzz_targets/load_wabt.rs b/fuzz/fuzz_targets/load_wabt.rs new file mode 100644 index 0000000..0c98907 --- /dev/null +++ b/fuzz/fuzz_targets/load_wabt.rs @@ -0,0 +1,13 @@ +#![no_main] +#[macro_use] +extern crate libfuzzer_sys; +extern crate wabt; +extern crate wasmi; + +fuzz_target!(|data: &[u8]| { + let wasmi_result = wasmi::Module::from_buffer(data); + let wabt_result = + wabt::Module::read_binary(data, &Default::default()).and_then(|m| m.validate()); + + assert_eq!(wasmi_result.is_ok(), wabt_result.is_ok()); +});