decode ipld cargo fuzz harness
This commit is contained in:
parent
275b7615b8
commit
f5bbdcb8a2
4
fuzz/.gitignore
vendored
Normal file
4
fuzz/.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
target
|
||||
corpus
|
||||
artifacts
|
||||
coverage
|
28
fuzz/Cargo.toml
Normal file
28
fuzz/Cargo.toml
Normal file
@ -0,0 +1,28 @@
|
||||
[package]
|
||||
name = "ipfs-fuzz"
|
||||
version = "0.0.0"
|
||||
publish = false
|
||||
edition = "2018"
|
||||
|
||||
[package.metadata]
|
||||
cargo-fuzz = true
|
||||
|
||||
[dependencies]
|
||||
libfuzzer-sys = "0.4"
|
||||
cid = "*"
|
||||
|
||||
[dependencies.ipfs]
|
||||
path = ".."
|
||||
|
||||
# Prevent this from interfering with workspaces
|
||||
[workspace]
|
||||
members = ["."]
|
||||
|
||||
[profile.release]
|
||||
debug = 1
|
||||
|
||||
[[bin]]
|
||||
name = "decode_ipld"
|
||||
path = "fuzz_targets/decode_ipld.rs"
|
||||
test = false
|
||||
doc = false
|
13
fuzz/fuzz_targets/decode_ipld.rs
Normal file
13
fuzz/fuzz_targets/decode_ipld.rs
Normal file
@ -0,0 +1,13 @@
|
||||
#![no_main]
|
||||
use libfuzzer_sys::fuzz_target;
|
||||
use std::convert::TryFrom;
|
||||
|
||||
fuzz_target!(|data: (&str, &[u8])| {
|
||||
let _ = fuzz(data.0, data.1);
|
||||
});
|
||||
|
||||
fn fuzz(cid: &str, payload: &[u8]) -> Result<(), ()> {
|
||||
let cid = ipfs::Cid::try_from(cid).map_err(drop)?;
|
||||
let _ = ipfs::ipld::decode_ipld(&cid, payload).map_err(drop)?;
|
||||
Ok(())
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user