mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-16 11:58:08 +00:00
Add support for standalone leak-sanitizer, introducting the environment
variable AFL_USE_LSAN. AFL_USE_LSAN introduces the macro __AFL_CHECK_LEAK() which will check for a memory leak when the macro is run. This is especially helpful when using __AFL_LOOP(). If __AFL_LEAK_CHECK() is not used when AFL_USE_LSAN=1 is set, the leak checker will run when the program exits.
This commit is contained in:
16
src/afl-cc.c
16
src/afl-cc.c
@ -758,7 +758,7 @@ static void edit_params(u32 argc, char **argv, char **envp) {
|
||||
if (!strncmp(cur, "-fsanitize-coverage-", 20) && strstr(cur, "list="))
|
||||
have_instr_list = 1;
|
||||
|
||||
if (!strcmp(cur, "-fsanitize=address") || !strcmp(cur, "-fsanitize=memory"))
|
||||
if (!(strcmp(cur, "-fsanitize=address") && strcmp(cur, "-fsanitize=memory")))
|
||||
asan_set = 1;
|
||||
|
||||
if (strstr(cur, "FORTIFY_SOURCE")) fortify_set = 1;
|
||||
@ -817,6 +817,10 @@ static void edit_params(u32 argc, char **argv, char **envp) {
|
||||
|
||||
}
|
||||
|
||||
if (getenv("AFL_USE_LSAN")) {
|
||||
cc_params[cc_par_cnt++] = "-fsanitize=leak";
|
||||
}
|
||||
|
||||
if (getenv("AFL_USE_CFISAN")) {
|
||||
|
||||
if (!lto_mode) {
|
||||
@ -914,6 +918,13 @@ static void edit_params(u32 argc, char **argv, char **envp) {
|
||||
|
||||
}
|
||||
|
||||
if (getenv("AFL_USE_LSAN")) {
|
||||
cc_params[cc_par_cnt++] = "-includesanitizer/lsan_interface.h";
|
||||
}
|
||||
|
||||
cc_params[cc_par_cnt++] =
|
||||
"-D__AFL_CHECK_LEAK()=__lsan_do_leak_check()";
|
||||
|
||||
cc_params[cc_par_cnt++] =
|
||||
"-D__AFL_COVERAGE_START_OFF()=int __afl_selective_coverage_start_off = "
|
||||
"1;";
|
||||
@ -1740,7 +1751,8 @@ int main(int argc, char **argv, char **envp) {
|
||||
" AFL_USE_ASAN: activate address sanitizer\n"
|
||||
" AFL_USE_CFISAN: activate control flow sanitizer\n"
|
||||
" AFL_USE_MSAN: activate memory sanitizer\n"
|
||||
" AFL_USE_UBSAN: activate undefined behaviour sanitizer\n");
|
||||
" AFL_USE_UBSAN: activate undefined behaviour sanitizer\n"
|
||||
" AFL_USE_LSAN: activate leak-checker sanitizer\n");
|
||||
|
||||
if (have_gcc_plugin)
|
||||
SAYF(
|
||||
|
Reference in New Issue
Block a user