Non weak default sanitizers options functions (#519)

This commit is contained in:
Andrea Fioraldi 2022-02-03 10:44:23 +01:00 committed by GitHub
parent 0062bab412
commit f527aab15e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 7 deletions

View File

@ -11,9 +11,10 @@ keywords = ["fuzzing", "testing"]
edition = "2021" edition = "2021"
[features] [features]
default = ["std"] default = ["std", "sanitizers_flags"]
std = ["libafl/std"] std = ["libafl/std"]
libfuzzer = [] libfuzzer = []
sanitizers_flags = []
pointer_maps = [] pointer_maps = []
sancov_pcguard_edges = [] sancov_pcguard_edges = []
sancov_pcguard_hitcounts = [] sancov_pcguard_hitcounts = []

View File

@ -92,9 +92,14 @@ fn main() {
println!("cargo:rerun-if-changed=src/common.h"); println!("cargo:rerun-if-changed=src/common.h");
println!("cargo:rerun-if-changed=src/common.c"); println!("cargo:rerun-if-changed=src/common.c");
cc::Build::new() let mut common = cc::Build::new();
.file(src_dir.join("common.c"))
.compile("common"); #[cfg(feature = "sanitizers_flags")]
{
common.define("DEFAULT_SANITIZERS_OPTIONS", "1");
}
common.file(src_dir.join("common.c")).compile("common");
println!("cargo:rerun-if-changed=src/coverage.c"); println!("cargo:rerun-if-changed=src/coverage.c");

View File

@ -1,6 +1,9 @@
#include "common.h" #include "common.h"
EXT_FUNC_IMPL(__asan_default_options, const char*, (), false) { #ifdef DEFAULT_SANITIZERS_OPTIONS
// TODO MSan and LSan. however they don't support abort_on_error
const char* __asan_default_options() {
return "abort_on_error=1:detect_leaks=0:" return "abort_on_error=1:detect_leaks=0:"
"malloc_context_size=0:symbolize=0:" "malloc_context_size=0:symbolize=0:"
"allocator_may_return_null=1:" "allocator_may_return_null=1:"
@ -9,7 +12,7 @@ EXT_FUNC_IMPL(__asan_default_options, const char*, (), false) {
"handle_sigfpe=0:handle_sigill=0"; "handle_sigfpe=0:handle_sigill=0";
} }
EXT_FUNC_IMPL(__ubsan_default_options, const char*, (), false) { const char* __ubsan_default_options() {
return "abort_on_error=1:" return "abort_on_error=1:"
"allocator_release_to_os_interval_ms=500:" "allocator_release_to_os_interval_ms=500:"
"handle_abort=0:handle_segv=0:" "handle_abort=0:handle_segv=0:"
@ -17,4 +20,4 @@ EXT_FUNC_IMPL(__ubsan_default_options, const char*, (), false) {
"handle_sigill=0:print_stacktrace=0:" "handle_sigill=0:print_stacktrace=0:"
"symbolize=0:symbolize_inline_frames=0"; "symbolize=0:symbolize_inline_frames=0";
} }
#endif // DEFAULT_SANITIZERS_OPTIONS