diff options
author | Joel Galenson <jgalenson@google.com> | 2021-07-02 16:42:37 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-07-02 16:42:37 +0000 |
commit | f641a203437ce4f633f8b2353646d5bfbb6cb60f (patch) | |
tree | 7696ff23d6a2a0ae49c20e4bcfae2561022b8406 | |
parent | 9735c131ac7902cd180302ce84956eb49067cc74 (diff) | |
parent | 456a892a9be4902f9b31b00e69ac039768354ff7 (diff) | |
download | libfuzzer-sys-f641a203437ce4f633f8b2353646d5bfbb6cb60f.tar.gz |
Upgrade rust/crates/libfuzzer-sys to 0.4.2 am: 577945a102 am: 6d1535b6bc am: 456a892a9b
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/libfuzzer-sys/+/1742518
Change-Id: I05ceae5ae9a7e71d59681ca8e7fd7c3937e063e1
-rw-r--r-- | .cargo_vcs_info.json | 2 | ||||
-rw-r--r-- | Android.bp | 4 | ||||
-rw-r--r-- | CHANGELOG.md | 13 | ||||
-rw-r--r-- | Cargo.toml | 5 | ||||
-rw-r--r-- | Cargo.toml.orig | 3 | ||||
-rw-r--r-- | METADATA | 8 | ||||
-rwxr-xr-x | ci/script.sh | 2 | ||||
-rw-r--r-- | src/lib.rs | 22 |
8 files changed, 48 insertions, 11 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index 99e3306..4d6cfd1 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,5 +1,5 @@ { "git": { - "sha1": "062f36b424c6dcdbd403c3a5d4384d731c8a3f84" + "sha1": "a89115ac1105fa0c7c7d9cb5cdb479af36031aff" } } @@ -43,6 +43,7 @@ rust_library_rlib { features: ["arbitrary-derive"], rustlibs: [ "libarbitrary", + "libonce_cell", ], } @@ -50,7 +51,8 @@ rust_library_rlib { // arbitrary-1.0.1 "derive,derive_arbitrary" // cc-1.0.68 // derive_arbitrary-1.0.1 +// once_cell-1.8.0 "alloc,default,race,std" // proc-macro2-1.0.27 "default,proc-macro" // quote-1.0.9 "default,proc-macro" -// syn-1.0.72 "clone-impls,default,derive,parsing,printing,proc-macro,quote" +// syn-1.0.73 "clone-impls,default,derive,parsing,printing,proc-macro,quote" // unicode-xid-0.2.2 "default" diff --git a/CHANGELOG.md b/CHANGELOG.md index f0e6039..77be1fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,19 @@ Released YYYY-MM-DD. -------------------------------------------------------------------------------- +## 0.4.2 + +Released 2020-05-26. + +### Changed + +* Improved performance of checking for whether `cargo fuzz` is requesting the + `std::fmt::Debug` output of an input or not. This is always false during + regular fuzzing, so making this check faster should give slightly better + fuzzing throughput. + +-------------------------------------------------------------------------------- + ## 0.4.1 Released 2020-05-13. @@ -13,7 +13,7 @@ [package] edition = "2018" name = "libfuzzer-sys" -version = "0.4.1" +version = "0.4.2" authors = ["The rust-fuzz Project Developers"] description = "A wrapper around LLVM's libFuzzer runtime." readme = "./README.md" @@ -21,6 +21,9 @@ license = "MIT/Apache-2.0/NCSA" repository = "https://github.com/rust-fuzz/libfuzzer" [dependencies.arbitrary] version = "1" + +[dependencies.once_cell] +version = "1" [dev-dependencies.flate2] version = "1.0.20" diff --git a/Cargo.toml.orig b/Cargo.toml.orig index adfe66d..72285b9 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -6,10 +6,11 @@ license = "MIT/Apache-2.0/NCSA" name = "libfuzzer-sys" readme = "./README.md" repository = "https://github.com/rust-fuzz/libfuzzer" -version = "0.4.1" +version = "0.4.2" [dependencies] arbitrary = "1" +once_cell = "1" [build-dependencies] cc = "1.0" @@ -7,13 +7,13 @@ third_party { } url { type: ARCHIVE - value: "https://static.crates.io/crates/libfuzzer-sys/libfuzzer-sys-0.4.1.crate" + value: "https://static.crates.io/crates/libfuzzer-sys/libfuzzer-sys-0.4.2.crate" } - version: "0.4.1" + version: "0.4.2" license_type: NOTICE last_upgrade_date { year: 2021 - month: 5 - day: 19 + month: 6 + day: 21 } } diff --git a/ci/script.sh b/ci/script.sh index b94de7b..91fad80 100755 --- a/ci/script.sh +++ b/ci/script.sh @@ -56,3 +56,5 @@ cargo rustc \ -Zsanitizer=address (! $CARGO_TARGET_DIR/release/example_mutator -runs=10000000) popd + +echo "All good!" @@ -12,6 +12,7 @@ #![deny(missing_docs, missing_debug_implementations)] pub use arbitrary; +use once_cell::sync::OnceCell; extern "C" { // We do not actually cross the FFI bound here. @@ -37,6 +38,9 @@ pub fn test_input_wrap(data: *const u8, size: usize) -> i32 { } #[doc(hidden)] +pub static RUST_LIBFUZZER_DEBUG_PATH: OnceCell<String> = OnceCell::new(); + +#[doc(hidden)] #[export_name = "LLVMFuzzerInitialize"] pub fn initialize(_argc: *const isize, _argv: *const *const *const u8) -> isize { // Registers a panic hook that aborts the process before unwinding. @@ -52,6 +56,14 @@ pub fn initialize(_argc: *const isize, _argv: *const *const *const u8) -> isize default_hook(panic_info); ::std::process::abort(); })); + + // Initialize the `RUST_LIBFUZZER_DEBUG_PATH` cell with the path so it can be + // reused with little overhead. + if let Ok(path) = std::env::var("RUST_LIBFUZZER_DEBUG_PATH") { + RUST_LIBFUZZER_DEBUG_PATH + .set(path) + .expect("Since this is initialize it is only called once so can never fail"); + } 0 } @@ -130,7 +142,9 @@ macro_rules! fuzz_target { // When `RUST_LIBFUZZER_DEBUG_PATH` is set, write the debug // formatting of the input to that file. This is only intended for // `cargo fuzz`'s use! - if let Ok(path) = std::env::var("RUST_LIBFUZZER_DEBUG_PATH") { + + // `RUST_LIBFUZZER_DEBUG_PATH` is set in initialization. + if let Some(path) = $crate::RUST_LIBFUZZER_DEBUG_PATH.get() { use std::io::Write; let mut file = std::fs::File::create(path) .expect("failed to create `RUST_LIBFUZZER_DEBUG_PATH` file"); @@ -151,7 +165,7 @@ macro_rules! fuzz_target { /// Auto-generated function #[no_mangle] pub extern "C" fn rust_fuzzer_test_input(bytes: &[u8]) { - use libfuzzer_sys::arbitrary::{Arbitrary, Unstructured}; + use $crate::arbitrary::{Arbitrary, Unstructured}; // Early exit if we don't have enough bytes for the `Arbitrary` // implementation. This helps the fuzzer avoid exploring all the @@ -169,7 +183,9 @@ macro_rules! fuzz_target { // When `RUST_LIBFUZZER_DEBUG_PATH` is set, write the debug // formatting of the input to that file. This is only intended for // `cargo fuzz`'s use! - if let Ok(path) = std::env::var("RUST_LIBFUZZER_DEBUG_PATH") { + + // `RUST_LIBFUZZER_DEBUG_PATH` is set in initialization. + if let Some(path) = $crate::RUST_LIBFUZZER_DEBUG_PATH.get() { use std::io::Write; let mut file = std::fs::File::create(path) .expect("failed to create `RUST_LIBFUZZER_DEBUG_PATH` file"); |