Skip to content

Commit

Permalink
Add a roundtrip fuzz target (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shnatsel committed Apr 11, 2023
1 parent d962c3e commit ee29e37
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
13 changes: 8 additions & 5 deletions fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,14 @@ members = ["."]
name = "fuzz_high"
path = "fuzz_targets/fuzz_high.rs"

[features]
default = ["fuzzing"]
fuzzing = ["miniz_oxide_c_api/fuzzing"]


[[bin]]
name = "inflate_nonwrapping"
path = "fuzz_targets/inflate_nonwrapping.rs"

[[bin]]
name = "roundtrip"
path = "fuzz_targets/roundtrip.rs"

[features]
default = ["fuzzing"]
fuzzing = ["miniz_oxide_c_api/fuzzing"]
11 changes: 11 additions & 0 deletions fuzz/fuzz_targets/roundtrip.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#![no_main]
#[macro_use] extern crate libfuzzer_sys;
extern crate miniz_oxide;

fuzz_target!(|input: (u8, Vec<u8>)| {
let compression_level = input.0;
let data = input.1;
let compressed = miniz_oxide::deflate::compress_to_vec(&data, compression_level);
let decompressed = miniz_oxide::inflate::decompress_to_vec(&compressed).expect("Failed to decompress compressed data!");
assert_eq!(data, decompressed);
});

0 comments on commit ee29e37

Please sign in to comment.