Skip to content

Commit

Permalink
Update fuzz framework
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexey Arbuzov committed Sep 24, 2024
1 parent afa9d5e commit 84c6795
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 89 deletions.
2 changes: 1 addition & 1 deletion fuzz/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

target
corpus
artifacts
coverage
96 changes: 32 additions & 64 deletions fuzz/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 15 additions & 13 deletions fuzz/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@

[package]
name = "tlv_parser-fuzz"
version = "0.0.1"
authors = ["Automatically generated"]
version = "0.0.0"
publish = false
edition = "2021"

[package.metadata]
cargo-fuzz = true

[dependencies]
libfuzzer-sys = "0.4"

[dependencies.tlv_parser]
path = ".."
[dependencies.libfuzzer-sys]
git = "https://github.com/rust-fuzz/libfuzzer-sys.git"

# Prevent this from interfering with workspaces
[workspace]
members = ["."]

[[bin]]
name = "fuzzer_script_1"
path = "fuzzers/fuzzer_script_1.rs"
name = "from_vec"
path = "fuzz_targets/from_vec.rs"
test = false
doc = false
bench = false

[[bin]]
name = "find-val"
path = "fuzzers/find-val.rs"
name = "find_val"
path = "fuzz_targets/find_val.rs"
test = false
doc = false
bench = false
6 changes: 2 additions & 4 deletions fuzz/fuzzers/find-val.rs → fuzz/fuzz_targets/find_val.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#![no_main]
#[macro_use]
extern crate libfuzzer_sys;
extern crate tlv_parser;

use tlv_parser::tlv::*;
use libfuzzer_sys::fuzz_target;
use tlv_parser::tlv::{Tlv, Value};

fuzz_target!(|data: &[u8]| {
let tlv = Tlv::new(0x6a, Value::Nothing).unwrap();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
#![no_main]
#[macro_use] extern crate libfuzzer_sys;
extern crate tlv_parser;

use tlv_parser::*;
use libfuzzer_sys::fuzz_target;
use tlv_parser::tlv::Tlv;

fuzz_target!(|data: &[u8]| {
// fuzzed code goes here
match tlv::Tlv::from_vec(data) {
match Tlv::from_vec(data) {
Ok(tlv) => {
let restored_tlv = tlv.to_vec();
assert!(!restored_tlv.is_empty());
},
}
Err(_) => (),
}
});

0 comments on commit 84c6795

Please sign in to comment.