Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Add fuzz target for cranelift_reader::parse_test.
Browse files Browse the repository at this point in the history
  • Loading branch information
frewsxcv authored and sunfishcode committed Jul 24, 2018
1 parent 8b722d4 commit 01de684
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ cargo-fuzz = "*"
binaryen = { git = "https://github.com/pepyakin/binaryen-rs.git" }
libfuzzer-sys = { git = "https://github.com/rust-fuzz/libfuzzer-sys.git" }
cranelift-wasm = { path = "../lib/wasm" }
cranelift-reader = { path = "../lib/reader" }
target-lexicon = "0.0.3"

# Prevent this from interfering with workspaces
Expand All @@ -21,3 +22,7 @@ members = ["."]
[[bin]]
name = "fuzz_translate_module"
path = "fuzz_translate_module.rs"

[[bin]]
name = "fuzz_reader_parse_test"
path = "fuzz_reader_parse_test.rs"
11 changes: 11 additions & 0 deletions fuzz/fuzz_reader_parse_test.rs
Original file line number Diff line number Diff line change
@@ -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);
}
});

0 comments on commit 01de684

Please sign in to comment.