forked from rust-lang/flate2-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial oss-fuzz integration. (rust-lang#267)
- Loading branch information
1 parent
f9e26de
commit 7546110
Showing
3 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
target | ||
corpus | ||
artifacts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
|
||
[package] | ||
name = "flate2-fuzz" | ||
version = "0.0.0" | ||
authors = ["Automatically generated"] | ||
publish = false | ||
edition = "2018" | ||
|
||
[package.metadata] | ||
cargo-fuzz = true | ||
|
||
[dependencies] | ||
libfuzzer-sys = "0.4" | ||
flate2 = { path = ".." } | ||
|
||
# Prevent this from interfering with workspaces | ||
[workspace] | ||
members = ["."] | ||
|
||
[[bin]] | ||
name = "fuzz_gz_roundtrip" | ||
path = "fuzz_targets/fuzz_gz_roundtrip.rs" | ||
test = false | ||
doc = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#![no_main] | ||
use libfuzzer_sys::fuzz_target; | ||
use flate2::write::GzEncoder; | ||
use flate2::Compression; | ||
use flate2::read::GzDecoder; | ||
use std::io::prelude::*; | ||
|
||
|
||
fuzz_target!(|data: &[u8]| { | ||
let mut encoder = GzEncoder::new(Vec::new(), Compression::default()); | ||
encoder.write_all(data).unwrap(); | ||
let result = encoder.finish().unwrap(); | ||
let mut r = GzDecoder::new(&result[..]); | ||
let mut ret = Vec::new(); | ||
r.read_to_end(&mut ret).unwrap(); | ||
assert!(ret == data); | ||
}); |