Add signal option to forkserver_simple (#548)

This commit is contained in:
Tamas K Lengyel 2022-02-21 10:49:04 -05:00 committed by GitHub
parent ba4cca0e15
commit b3d68e8f40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 3 deletions

View File

@ -18,3 +18,4 @@ opt-level = 3
[dependencies]
libafl = { path = "../../libafl/" }
clap = { version = "3.0", features = ["default"] }
nix = "0.23"

View File

@ -1,3 +1,4 @@
use clap::{App, Arg};
use core::time::Duration;
use libafl::{
bolts::{
@ -23,10 +24,9 @@ use libafl::{
stages::mutational::StdMutationalStage,
state::{HasCorpus, HasMetadata, StdState},
};
use nix::sys::signal::Signal;
use std::path::PathBuf;
use clap::{App, Arg};
#[allow(clippy::similar_names)]
pub fn main() {
let res = App::new("forkserver_simple")
@ -62,6 +62,13 @@ pub fn main() {
.setting(clap::ArgSettings::MultipleValues)
.takes_value(true),
)
.arg(
Arg::new("signal")
.help("Signal used to stop child")
.short('s')
.long("signal")
.default_value("SIGKILL"),
)
.get_matches();
let corpus_dirs = vec![PathBuf::from(res.value_of("in").unwrap().to_string())];
@ -155,7 +162,7 @@ pub fn main() {
.build(tuple_list!(time_observer, edges_observer))
.unwrap();
let mut executor = TimeoutForkserverExecutor::new(
let mut executor = TimeoutForkserverExecutor::with_signal(
forkserver,
Duration::from_millis(
res.value_of("timeout")
@ -164,6 +171,7 @@ pub fn main() {
.parse()
.expect("Could not parse timeout in milliseconds"),
),
res.value_of("signal").unwrap().parse::<Signal>().unwrap(),
)
.expect("Failed to create the executor.");