diff --git a/fuzz/process/.gitignore b/fuzz/process/.gitignore new file mode 100644 index 0000000..e9e2199 --- /dev/null +++ b/fuzz/process/.gitignore @@ -0,0 +1,2 @@ +/target/ +/Cargo.lock diff --git a/fuzz/process/Cargo.toml b/fuzz/process/Cargo.toml new file mode 100644 index 0000000..ac88325 --- /dev/null +++ b/fuzz/process/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "hyperbuild-fuzz-process" +version = "0.0.1" +authors = ["Wilson Lin "] +edition = "2018" + +[dependencies] +hyperbuild = { path = "../.." } diff --git a/fuzz/process/src/main.rs b/fuzz/process/src/main.rs new file mode 100644 index 0000000..e7d2563 --- /dev/null +++ b/fuzz/process/src/main.rs @@ -0,0 +1,21 @@ +use std::fs; +use std::io::{self, Write}; +use std::panic; +use hyperbuild; + +fn main() { + for dirent in fs::read_dir("../out/crashes").unwrap() { + let path = dirent.unwrap().path().to_path_buf(); + let path_in_catch = path.clone(); + let res = panic::catch_unwind(|| { + let mut contents = fs::read(path_in_catch).unwrap(); + let _ = hyperbuild::hyperbuild(&mut contents); + }); + if res.is_err() { + let contents = fs::read(path).unwrap(); + io::stdout().write_all(&contents).unwrap(); + break; + }; + fs::remove_file(path).unwrap(); + }; +}