Skip to content

Commit

Permalink
Merge torrust#3: Add cargo-fuzz fuzzer
Browse files Browse the repository at this point in the history
a1597cc Add cargo-fuzz fuzzer (5225225)

Pull request description:

  From: #29
  By: [5225225](https://github.com/5225225)

  `This adds a https://github.com/rust-fuzz/cargo-fuzz fuzzer which I used to find #28`

ACKs for top commit:
  josecelano:
    ACK a1597cc

Tree-SHA512: 45c604038a0e48b3057612ff4a28ffce1f4985f94c8fc3807d08daff8e94f7f40173bb690296619f928075101d2712abd984ec27849d12621a72606113baa501
  • Loading branch information
josecelano committed Sep 25, 2023
2 parents 686a005 + a1597cc commit a0947d7
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
3 changes: 3 additions & 0 deletions fuzz/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
target
corpus
artifacts
25 changes: 25 additions & 0 deletions fuzz/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[package]
name = "serde_bencode-fuzz"
version = "0.0.0"
authors = ["Automatically generated"]
publish = false
edition = "2018"

[package.metadata]
cargo-fuzz = true

[dependencies]
libfuzzer-sys = "0.4"

[dependencies.serde_bencode]
path = ".."

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

[[bin]]
name = "from_bytes"
path = "fuzz_targets/from_bytes.rs"
test = false
doc = false
9 changes: 9 additions & 0 deletions fuzz/fuzz_targets/from_bytes.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#![no_main]
use libfuzzer_sys::fuzz_target;

use serde_bencode::value::Value;
use serde_bencode::from_bytes;

fuzz_target!(|data: &[u8]| {
let _: Result<Value, _> = from_bytes(data);
});

0 comments on commit a0947d7

Please sign in to comment.