fuzz: Update fuzzer targets for recent changes

This commit is contained in:
Jack Grigg 2021-12-23 17:01:46 +00:00
parent 5207877992
commit 81f91581bf
2 changed files with 5 additions and 3 deletions

View file

@ -7,7 +7,7 @@ fuzz_target!(|data: &[u8]| {
if let Ok((leftover, stanza)) = read::age_stanza(data) { if let Ok((leftover, stanza)) = read::age_stanza(data) {
let mut buf = Vec::with_capacity(data.len()); let mut buf = Vec::with_capacity(data.len());
gen( gen(
write::age_stanza(stanza.tag, &stanza.args, &stanza.body), write::age_stanza(stanza.tag, &stanza.args, &stanza.body()),
&mut buf, &mut buf,
) )
.expect("can write to Vec"); .expect("can write to Vec");

View file

@ -1,16 +1,18 @@
#![no_main] #![no_main]
use libfuzzer_sys::fuzz_target; use libfuzzer_sys::fuzz_target;
use std::iter;
use age::Decryptor; use age::Decryptor;
fuzz_target!(|data: &[u8]| { fuzz_target!(|data: &[u8]| {
if let Ok(decryptor) = Decryptor::new(data) { if let Ok(decryptor) = Decryptor::new(data) {
match decryptor { match decryptor {
Decryptor::Recipients(d) => { Decryptor::Recipients(d) => {
let _ = d.decrypt(&[]); let _ = d.decrypt(iter::empty());
} }
// Don't pay the cost of scrypt while fuzzing. // Don't pay the cost of scrypt while fuzzing.
Decryptor::Passphrase(_) => () Decryptor::Passphrase(_) => (),
} }
} }
}); });