From 9c3d1526187ee0d40503897292fd2c2d8a47a88d Mon Sep 17 00:00:00 2001 From: Xander Bil Date: Tue, 29 Oct 2024 22:18:41 +0100 Subject: [PATCH] add fuzzer --- fuzz/Cargo.toml | 7 +++++++ fuzz/fuzz_targets/parser.rs | 7 ++++++- fuzz/fuzz_targets/parser_to_bytes.rs | 8 ++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 fuzz/fuzz_targets/parser_to_bytes.rs diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index 0c67660..9cd1a75 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -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 diff --git a/fuzz/fuzz_targets/parser.rs b/fuzz/fuzz_targets/parser.rs index 254a549..fcc923b 100644 --- a/fuzz/fuzz_targets/parser.rs +++ b/fuzz/fuzz_targets/parser.rs @@ -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); }); + diff --git a/fuzz/fuzz_targets/parser_to_bytes.rs b/fuzz/fuzz_targets/parser_to_bytes.rs new file mode 100644 index 0000000..855e46c --- /dev/null +++ b/fuzz/fuzz_targets/parser_to_bytes.rs @@ -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); +});