Skip to content

Commit

Permalink
fix error printing
Browse files Browse the repository at this point in the history
  • Loading branch information
hkctkuy authored and hkctkuy committed Aug 21, 2023
1 parent a182101 commit 470cf3b
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 51 deletions.
33 changes: 17 additions & 16 deletions casr/src/bin/casr-afl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,11 @@ fn main() -> Result<()> {
.join(
|| {
crashes.par_iter().try_for_each(|(_, crash)| {
let Ok(_) = crash.run_casr(output_dir.as_path(), timeout) else {
// Disable util::log_progress
*counter.write().unwrap() = total;
bail!("Casr run error");
};
if let Err(e) = crash.run_casr(output_dir.as_path(), timeout) {
// Disable util::log_progress
*counter.write().unwrap() = total;
bail!(e);
};
*counter.write().unwrap() += 1;
Ok::<(), anyhow::Error>(())
})
Expand Down Expand Up @@ -406,17 +406,18 @@ fn summarize_results(
.join(
|| {
crashes.par_iter().try_for_each(|crash| {
let Ok(_) = AflCrashInfo {
path: crash.to_path_buf(),
target_args: gdb_args.clone(),
at_index,
is_asan: false,
}
.run_casr(None, timeout) else {
// Disable util::log_progress
*counter.write().unwrap() = total;
bail!("Casr run error");
};
if let Err(e) = (AflCrashInfo {
path: crash.to_path_buf(),
target_args: gdb_args.clone(),
at_index,
is_asan: false,
})
.run_casr(None, timeout)
{
// Disable util::log_progress
*counter.write().unwrap() = total;
bail!(e);
};
*counter.write().unwrap() += 1;
Ok::<(), anyhow::Error>(())
})
Expand Down
70 changes: 35 additions & 35 deletions casr/src/bin/casr-libfuzzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,44 +180,44 @@ fn main() -> Result<()> {
custom_pool
.join(
|| {
let Ok (_) = crashes.par_iter().try_for_each(|(crash, fname)| {
let mut casr_cmd = Command::new(tool);
if timeout != 0 {
casr_cmd.args(["-t".to_string(), timeout.to_string()]);
}
casr_cmd.args([
"-o",
format!("{}.casrep", output_dir.join(fname).display()).as_str(),
"--",
]);
if !atheris_asan_lib.is_empty() {
casr_cmd.arg("python3");
casr_cmd.env("LD_PRELOAD", &atheris_asan_lib);
}
casr_cmd.args(argv.clone());
casr_cmd.arg(crash);
debug!("{:?}", casr_cmd);
if let Err(e) = crashes.par_iter().try_for_each(|(crash, fname)| {
let mut casr_cmd = Command::new(tool);
if timeout != 0 {
casr_cmd.args(["-t".to_string(), timeout.to_string()]);
}
casr_cmd.args([
"-o",
format!("{}.casrep", output_dir.join(fname).display()).as_str(),
"--",
]);
if !atheris_asan_lib.is_empty() {
casr_cmd.arg("python3");
casr_cmd.env("LD_PRELOAD", &atheris_asan_lib);
}
casr_cmd.args(argv.clone());
casr_cmd.arg(crash);
debug!("{:?}", casr_cmd);

// Get output
let casr_output = casr_cmd
.output()
.with_context(|| format!("Couldn't launch {casr_cmd:?}"))?;
// Get output
let casr_output = casr_cmd
.output()
.with_context(|| format!("Couldn't launch {casr_cmd:?}"))?;

if !casr_output.status.success() {
let err = String::from_utf8_lossy(&casr_output.stderr);
if err.contains("Program terminated (no crash)") {
warn!("{}: no crash on input {}", tool, crash.display());
} else {
error!("{} for input: {}", err.trim(), crash.display());
if !casr_output.status.success() {
let err = String::from_utf8_lossy(&casr_output.stderr);
if err.contains("Program terminated (no crash)") {
warn!("{}: no crash on input {}", tool, crash.display());
} else {
error!("{} for input: {}", err.trim(), crash.display());
}
}
}
*counter.write().unwrap() += 1;
Ok::<(), anyhow::Error>(())
}) else {
// Disable util::log_progress
*counter.write().unwrap() = total;
bail!("Casr run error");
};
*counter.write().unwrap() += 1;
Ok::<(), anyhow::Error>(())
}) {
// Disable util::log_progress
*counter.write().unwrap() = total;
bail!(e);
};
Ok(())
},
|| util::log_progress(&counter, total),
Expand Down

0 comments on commit 470cf3b

Please sign in to comment.