diff options
author | Joshua Rogers <jrogers@opera.com> | 2021-04-02 22:23:11 +0000 |
---|---|---|
committer | Joshua Rogers <jrogers@opera.com> | 2021-04-02 22:23:11 +0000 |
commit | 920e9402a4d6101bbbed2ef7584d85a3c3de0eaa (patch) | |
tree | c8d8a258835b09099a30d9302ef0a9114a3ecae2 /src/afl-fuzz-init.c | |
parent | e98cd008222aa3bfea9b696ad756163302437eb3 (diff) | |
download | afl++-920e9402a4d6101bbbed2ef7584d85a3c3de0eaa.tar.gz |
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.
Diffstat (limited to 'src/afl-fuzz-init.c')
-rw-r--r-- | src/afl-fuzz-init.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/afl-fuzz-init.c b/src/afl-fuzz-init.c index 82c1799e..24f5c5b5 100644 --- a/src/afl-fuzz-init.c +++ b/src/afl-fuzz-init.c @@ -2466,6 +2466,20 @@ void check_asan_opts(afl_state_t *afl) { } + x = get_afl_env("LSAN_OPTIONS"); + + if (x) { + + if (!strstr(x, "exit_code=" STRINGIFY(LSAN_ERROR))) { + + FATAL("Custom LSAN_OPTIONS set without exit_code=" STRINGIFY( + LSAN_ERROR) " - please fix!"); + + } + + } + + } /* Handle stop signal (Ctrl-C, etc). */ @@ -2711,7 +2725,8 @@ void check_binary(afl_state_t *afl, u8 *fname) { } if (memmem(f_data, f_len, "__asan_init", 11) || - memmem(f_data, f_len, "__msan_init", 11)) { + memmem(f_data, f_len, "__msan_init", 11) || + memmem(f_data, f_len, "__lsan_init", 11)) { afl->fsrv.uses_asan = 1; |