abort() when the weakly defined LLVMFuzzerTestOneInput is linked(#2289)

This commit is contained in:
Dongjia "toka" Zhang 2024-06-07 23:54:19 +02:00 committed by GitHub
parent 14263b9c69
commit 1e2fac6f53
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 3 deletions

View File

@ -1,5 +1,8 @@
#include "common.h"
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#ifdef __APPLE__
#include <malloc/malloc.h>
#else
@ -18,6 +21,8 @@ EXT_FUNC(LLVMFuzzerCustomCrossOver, size_t,
false);
EXT_FUNC_IMPL(LLVMFuzzerTestOneInput, int, (const uint8_t *Data, size_t Size),
false) {
fprintf(stderr, "Weakly defined \"LLVMFuzzerTestOneInput\" is linked. Did you add extern \"C\" to your harness?\n");
abort();
return 0;
}

View File

@ -4,7 +4,7 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
LIBAFL_DIR=$(realpath "$SCRIPT_DIR/..")
if [ "$1" = "check" ]; then
cargo run --manifest-path "$LIBAFL_DIR/utils/libafl_fmt/Cargo.toml" --release -- -c
cargo run --manifest-path "$LIBAFL_DIR/utils/libafl_fmt/Cargo.toml" --release -- -c --verbose
else
cargo run --manifest-path "$LIBAFL_DIR/utils/libafl_fmt/Cargo.toml" --release
cargo run --manifest-path "$LIBAFL_DIR/utils/libafl_fmt/Cargo.toml" --release -- --verbose
fi

View File

@ -31,7 +31,7 @@ async fn run_cargo_fmt(path: PathBuf, is_check: bool, verbose: bool) -> io::Resu
let res = fmt_command.output().await?;
if !res.status.success() {
println!("{}", from_utf8(&res.stdout).unwrap());
println!("{}", from_utf8(&res.stderr).unwrap());
return Err(io::Error::new(ErrorKind::Other, "Cargo fmt failed."));
}
@ -96,6 +96,7 @@ async fn main() -> io::Result<()> {
r".*utils/gdb_qemu.*",
r".*docs/listings/baby_fuzzer/listing-.*",
r".*LibAFL/Cargo.toml.*",
r".*AFLplusplus.*",
])
.expect("Could not create the regex set from the given regex");
@ -105,6 +106,7 @@ async fn main() -> io::Result<()> {
r".*stb_image\.h$",
r".*dlmalloc\.c$",
r".*QEMU-Nyx.*",
r".*AFLplusplus.*",
])
.expect("Could not create the regex set from the given regex");