save ondisk

This commit is contained in:
Andrea Fioraldi 2021-02-15 12:19:58 +01:00
parent 746d2a326e
commit d16fd07beb
4 changed files with 22 additions and 1 deletions

4
.gitignore vendored
View File

@ -10,9 +10,11 @@ Cargo.lock
*.dll
*.exe
crashes
callgrind.out.*
perf.data
perf.data.old
.vscode
test.dict
test.dict

View File

@ -59,6 +59,7 @@ where
}
_ => {}
}
entry.store_input().expect("Could not save testcase to disk".into());
self.entries.push(RefCell::new(entry));
self.entries.len() - 1
}

View File

@ -41,6 +41,22 @@ where
Ok(self.input.as_ref().unwrap())
}
/// Store the input to disk if possible
pub fn store_input(&mut self) -> Result<bool, AflError> {
let fname;
match self.filename() {
Some(f) => { fname = f.clone(); },
None => { return Ok(false); }
};
match self.input_mut() {
None => Ok(false),
Some(i) => {
i.to_file(fname)?;
Ok(true)
}
}
}
/// Get the input, if any
#[inline]
pub fn input(&self) -> &Option<I> {

View File

@ -1,5 +1,7 @@
#!/bin/sh
mkdir -p ./crashes
cargo build --release || exit 1
cp ../../target/release/libfuzzer ./.libfuzzer_test.elf