Add fuzz target for cranelift_reader::parse_test.

This commit is contained in:
Corey Farwell
2018-07-24 09:59:21 -04:00
committed by Dan Gohman
parent eed861c6e1
commit 299898d494
2 changed files with 16 additions and 0 deletions

View File

@@ -12,6 +12,7 @@ cargo-fuzz = "*"
binaryen = { git = "https://github.com/pepyakin/binaryen-rs.git" } binaryen = { git = "https://github.com/pepyakin/binaryen-rs.git" }
libfuzzer-sys = { git = "https://github.com/rust-fuzz/libfuzzer-sys.git" } libfuzzer-sys = { git = "https://github.com/rust-fuzz/libfuzzer-sys.git" }
cranelift-wasm = { path = "../lib/wasm" } cranelift-wasm = { path = "../lib/wasm" }
cranelift-reader = { path = "../lib/reader" }
target-lexicon = "0.0.3" target-lexicon = "0.0.3"
# Prevent this from interfering with workspaces # Prevent this from interfering with workspaces
@@ -21,3 +22,7 @@ members = ["."]
[[bin]] [[bin]]
name = "fuzz_translate_module" name = "fuzz_translate_module"
path = "fuzz_translate_module.rs" path = "fuzz_translate_module.rs"
[[bin]]
name = "fuzz_reader_parse_test"
path = "fuzz_reader_parse_test.rs"

View File

@@ -0,0 +1,11 @@
#![no_main]
#[macro_use]
extern crate libfuzzer_sys;
extern crate cranelift_reader;
use std::str;
fuzz_target!(|data: &[u8]| {
if let Ok(s) = str::from_utf8(data) {
let _ = cranelift_reader::parse_test(s);
}
});