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

2
.gitignore vendored
View File

@ -10,6 +10,8 @@ Cargo.lock
*.dll *.dll
*.exe *.exe
crashes
callgrind.out.* callgrind.out.*
perf.data perf.data
perf.data.old perf.data.old

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.push(RefCell::new(entry));
self.entries.len() - 1 self.entries.len() - 1
} }

View File

@ -41,6 +41,22 @@ where
Ok(self.input.as_ref().unwrap()) 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 /// Get the input, if any
#[inline] #[inline]
pub fn input(&self) -> &Option<I> { pub fn input(&self) -> &Option<I> {

View File

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