Skip to content

Commit

Permalink
Merge #109
Browse files Browse the repository at this point in the history
109: Continuously libfuzz r=PaulGrandperrin a=killercup



Co-authored-by: Pascal Hertleif <killercup@gmail.com>
  • Loading branch information
bors[bot] and killercup committed Apr 27, 2018
2 parents 9254da3 + b365237 commit 06f6ed6
Showing 1 changed file with 33 additions and 24 deletions.
57 changes: 33 additions & 24 deletions cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,22 @@ fn run() -> Result<(), Error> {
.iter()
.filter(|x| filter.as_ref().map(|f| x.contains(f)).unwrap_or(true));

if infinite {
for target in targets.cycle() {
run(target)?;
'cycle: loop {
'targets_pass: for target in targets.clone() {
if let Err(e) = run(target) {
match e.downcast::<FuzzerQuit>() {
Ok(_) => {
println!("Fuzzer failed so we'll continue with the next one");
continue 'targets_pass;
},
Err(other_error) => Err(other_error)?,
}
}
}
} else {
for target in targets {
run(target)?;
if infinite {
run_cargo_update()?;
} else {
break 'cycle;
}
}
}
Expand Down Expand Up @@ -169,6 +178,15 @@ fn get_targets() -> Result<Vec<String>, Error> {
Ok(target_names.collect())
}

fn run_cargo_update() -> Result<(), Error> {
// TODO: https://github.com/rust-fuzz/targets/issues/106
Ok(())
}

#[derive(Fail, Debug)]
#[fail(display = "Fuzzer quit")]
pub struct FuzzerQuit;

fn run_honggfuzz(target: &str, timeout: Option<i32>) -> Result<(), Error> {
let fuzzer = Fuzzer::Honggfuzz;
write_fuzzer_target(fuzzer, target)?;
Expand Down Expand Up @@ -203,12 +221,9 @@ fn run_honggfuzz(target: &str, timeout: Option<i32>) -> Result<(), Error> {
fuzzer, target
))?;

ensure!(
fuzzer_bin.success(),
"{} quit with code {}",
fuzzer,
fuzzer_bin
);
if !fuzzer_bin.success() {
Err(FuzzerQuit)?;
}
Ok(())
}

Expand Down Expand Up @@ -236,12 +251,9 @@ fn run_afl(target: &str, _timeout: Option<i32>) -> Result<(), Error> {
fuzzer, target
))?;

ensure!(
fuzzer_bin.success(),
"{} quit with code {}",
fuzzer,
fuzzer_bin
);
if !fuzzer_bin.success() {
Err(FuzzerQuit)?;
}
Ok(())
}

Expand Down Expand Up @@ -296,12 +308,9 @@ fn run_libfuzzer(target: &str, timeout: Option<i32>) -> Result<(), Error> {
fuzzer, target
))?;

ensure!(
fuzzer_bin.success(),
"{} quit with code {}",
fuzzer,
fuzzer_bin
);
if !fuzzer_bin.success() {
Err(FuzzerQuit)?;
}
Ok(())
}

Expand Down

0 comments on commit 06f6ed6

Please sign in to comment.