2021-05-24 15:27:35 +00:00
|
|
|
#![no_main]
|
|
|
|
use libfuzzer_sys::fuzz_target;
|
2022-11-21 23:19:58 +00:00
|
|
|
use instant_smtp::types::Command;
|
2021-05-24 15:27:35 +00:00
|
|
|
|
|
|
|
fuzz_target!(|data: &[u8]| {
|
2022-11-21 23:19:58 +00:00
|
|
|
if let Ok((_, cmd)) = Command::from_bytes(data) {
|
2021-05-24 15:27:35 +00:00
|
|
|
// Fuzzer created a valid SMTP command.
|
|
|
|
// dbg!(&cmd);
|
|
|
|
|
|
|
|
let cmd2 = {
|
|
|
|
// Let's serialize the command into bytes ...
|
|
|
|
let mut buf = Vec::new();
|
|
|
|
cmd.serialize(&mut buf).unwrap();
|
|
|
|
|
|
|
|
// ... parse it again ...
|
2022-11-21 23:19:58 +00:00
|
|
|
let (rem, cmd2) = Command::from_bytes(&buf).unwrap();
|
2021-05-24 15:27:35 +00:00
|
|
|
assert!(rem.is_empty());
|
|
|
|
|
|
|
|
// dbg!(&cmd2);
|
|
|
|
cmd2
|
|
|
|
};
|
|
|
|
|
|
|
|
// ... and verify that we got the same results.
|
|
|
|
assert_eq!(cmd, cmd2);
|
|
|
|
}
|
|
|
|
});
|