Skip to content

Commit

Permalink
add fuzzer
Browse files Browse the repository at this point in the history
  • Loading branch information
xerbalind committed Oct 29, 2024
1 parent 341f79f commit 9c3d152
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
7 changes: 7 additions & 0 deletions fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,10 @@ path = "fuzz_targets/parser.rs"
test = false
doc = false
bench = false

[[bin]]
name = "parser_to_bytes"
path = "fuzz_targets/parser_to_bytes.rs"
test = false
doc = false
bench = false
7 changes: 6 additions & 1 deletion fuzz/fuzz_targets/parser.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
#![no_main]

use libfuzzer_sys::fuzz_target;
use zns::{parser::FromBytes, reader::Reader, structs::Message};
use zns::{
parser::{FromBytes},
reader::Reader,
structs::Message,
};

fuzz_target!(|data: &[u8]| {
let mut reader = Reader::new(data);
let _ = Message::from_bytes(&mut reader);
});

8 changes: 8 additions & 0 deletions fuzz/fuzz_targets/parser_to_bytes.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#![no_main]

use libfuzzer_sys::fuzz_target;
use zns::{parser::ToBytes, structs::Message};

fuzz_target!(|message: Message| {
let _ = Message::to_bytes(message);
});

0 comments on commit 9c3d152

Please sign in to comment.