From 7deb572dc58259ba64d191b4098d04d2ca778737 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Tue, 14 Jan 2020 11:53:44 -0800 Subject: [PATCH] Bump to version 0.2.0 and update README/Cargo.toml metadata Fixes #52 --- Cargo.toml | 17 ++++++----------- README.md | 37 ++++++++++++++++++++++++++----------- 2 files changed, 32 insertions(+), 22 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 491b565..447a56d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,16 +1,11 @@ [package] -name = "libfuzzer-sys" -version = "0.1.0" -authors = ["The cargo-fuzz Project Developers"] -repository = "https://github.com/rust-fuzz/libfuzzer-sys" -license = "MIT/Apache-2.0/NCSA" +authors = ["The rust-fuzz Project Developers"] edition = "2018" - -# cargo-fuzz puts this in a crate subdirectory, -# which causes problems if the crate uses workspaces. -# Create a useless local workspace to break out of this -[workspace] -members = ["."] +license = "MIT/Apache-2.0/NCSA" +name = "libfuzzer-sys" +readme = "./README.md" +repository = "https://github.com/rust-fuzz/libfuzzer" +version = "0.2.0" [dependencies] # arbitrary = "0.3" diff --git a/README.md b/README.md index 32f8c2c..14e1fd7 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,21 @@ -Barebones wrapper around libFuzzer runtime library. +# The `libfuzzer-sys` Crate + +Barebones wrapper around LLVM's libFuzzer runtime library. The CPP parts are extracted from compiler-rt git repository with `git filter-branch`. -libFuzzer relies on LLVM sanitizer support. The Rust compiler has built-in support for LLVM sanitizer support, for now, it's limited to Linux. As a result, libfuzzer-sys only works on Linux. +libFuzzer relies on LLVM sanitizer support. The Rust compiler has built-in support for LLVM sanitizer support, for now, it's limited to Linux. As a result, `libfuzzer-sys` only works on Linux. + +## Usage -# How to use +### Use `cargo fuzz`! -Use [cargo-fuzz]. +[The recommended way to use this crate with `cargo fuzz`!][cargo-fuzz]. [cargo-fuzz]: https://github.com/rust-fuzz/cargo-fuzz +### Manual Usage + This crate can also be used manually as following: First create a new cargo project: @@ -19,15 +25,15 @@ $ cargo new --bin fuzzed $ cd fuzzed ``` -Then add a dependency on the fuzzer-sys crate and your own crate: +Then add a dependency on the `fuzzer-sys` crate and your own crate: ```toml [dependencies] -libfuzzer-sys = { git = "https://github.com/rust-fuzz/libfuzzer-sys.git" } # will eventually publish to crates.io -your_crate = "*" # or something +libfuzzer-sys = "0.2.0" +your_crate = { path = "../path/to/your/crate" } ``` -and change the `src/main.rs` to fuzz your code: +Change the `fuzzed/src/main.rs` to fuzz your code: ```rust #![no_main] @@ -39,11 +45,19 @@ fuzz_target!(|data: &[u8]| { }); ``` -Finally, run the following commands: +Build by running the following command: +```sh +$ cargo rustc -- \ + -C passes='sancov' \ + -C llvm-args='-sanitizer-coverage-level=3' \ + -Z sanitizer=address ``` -$ cargo rustc -- -C passes='sancov' -C llvm-args='-sanitizer-coverage-level=3' -Z sanitizer=address -$ ./target/debug/fuzzed # runs fuzzing + +And finally, run the fuzzer: + +```sh +$ ./target/debug/fuzzed ``` ## Updating libfuzzer from upstream @@ -55,4 +69,5 @@ $ ./target/debug/fuzzed # runs fuzzing ## License All files in `libfuzzer` directory are licensed NCSA. + Everything else is dual-licensed Apache 2.0 and MIT.