diff --git a/libraries/cbor/fuzz/Cargo.toml b/libraries/cbor/fuzz/Cargo.toml new file mode 100644 index 0000000..439e4c0 --- /dev/null +++ b/libraries/cbor/fuzz/Cargo.toml @@ -0,0 +1,26 @@ + +[package] +name = "cbor-fuzz" +version = "0.0.0" +authors = ["Automatically generated"] +publish = false +edition = "2018" + +[package.metadata] +cargo-fuzz = true + +[dependencies] +libfuzzer-sys = "0.3" + +[dependencies.cbor] +path = ".." + +# Prevent this from interfering with workspaces +[workspace] +members = ["."] + +[[bin]] +name = "fuzz_target_1" +path = "fuzz_targets/fuzz_target_1.rs" +test = false +doc = false diff --git a/libraries/cbor/fuzz/fuzz_targets/fuzz_target_1.rs b/libraries/cbor/fuzz/fuzz_targets/fuzz_target_1.rs new file mode 100644 index 0000000..c83e339 --- /dev/null +++ b/libraries/cbor/fuzz/fuzz_targets/fuzz_target_1.rs @@ -0,0 +1,20 @@ +#![no_main] +#[macro_use] +extern crate libfuzzer_sys; +extern crate cbor; +extern crate alloc; + +use alloc::vec::Vec; + +fuzz_target!(|data: &[u8]| { + let encoded = cbor::read(data); + match encoded{ + Ok(value) => { + let mut decoded = Vec::new(); + let _ = cbor::write(value, &mut decoded); + assert_eq!(decoded, data); + } + Err(_) => {} + }; +}); +