diff --git a/CHANGELOG.md b/CHANGELOG.md index a924906..0fba42c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,18 @@ Released YYYY-MM-DD. -------------------------------------------------------------------------------- +## 0.4.6 + +Released 2023-01-26. + +### Fixed + +* Fixed a potential name conflict in functions generated by the `fuzz_target!` + macro. +* Fixed potential stale builds when updating custom libfuzzers to link against. + +-------------------------------------------------------------------------------- + ## 0.4.5 Released 2022-10-18. diff --git a/Cargo.toml b/Cargo.toml index bc5982d..1552302 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ license = "MIT/Apache-2.0/NCSA" name = "libfuzzer-sys" readme = "./README.md" repository = "https://github.com/rust-fuzz/libfuzzer" -version = "0.4.5" +version = "0.4.6" [dependencies] arbitrary = "1" diff --git a/build.rs b/build.rs index bf6c12f..ab1bbc5 100644 --- a/build.rs +++ b/build.rs @@ -1,10 +1,15 @@ fn main() { + println!("cargo:rerun-if-env-changed=CUSTOM_LIBFUZZER_PATH"); if let Ok(custom) = ::std::env::var("CUSTOM_LIBFUZZER_PATH") { + println!("cargo:rerun-if-changed={custom}"); + let custom_lib_path = ::std::path::PathBuf::from(&custom); let custom_lib_dir = custom_lib_path.parent().unwrap().to_string_lossy(); let custom_lib_name = custom_lib_path.file_stem().unwrap().to_string_lossy(); - let custom_lib_name = custom_lib_name.trim_start_matches("lib"); + let custom_lib_name = custom_lib_name + .strip_prefix("lib") + .unwrap_or(custom_lib_name.as_ref()); println!("cargo:rustc-link-search=native={}", custom_lib_dir); println!("cargo:rustc-link-lib=static={}", custom_lib_name); diff --git a/src/lib.rs b/src/lib.rs index ce1eb98..376feb9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -221,7 +221,7 @@ macro_rules! fuzz_target { return 0; } - run(bytes); + __libfuzzer_sys_run(bytes); 0 } @@ -234,11 +234,11 @@ macro_rules! fuzz_target { // panics in separate fuzzers can accidentally appear the same // because each fuzzer will have a function called // `rust_fuzzer_test_input`. By using a normal Rust function here - // it's named something like `the_fuzzer_name::_::run` which should + // it's named something like `the_fuzzer_name::_::__libfuzzer_sys_run` which should // ideally help prevent oss-fuzz from deduplicate fuzz bugs across // distinct targets accidentally. #[inline(never)] - fn run($bytes: &[u8]) { + fn __libfuzzer_sys_run($bytes: &[u8]) { $body } }; @@ -294,13 +294,13 @@ macro_rules! fuzz_target { Err(_) => return -1, }; - let result = ::libfuzzer_sys::Corpus::from(run(data)); + let result = ::libfuzzer_sys::Corpus::from(__libfuzzer_sys_run(data)); result.to_libfuzzer_code() } // See above for why this is split to a separate function. #[inline(never)] - fn run($data: $dty) -> $rty { + fn __libfuzzer_sys_run($data: $dty) -> $rty { $body } };