From: Kostya Serebryany Date: Tue, 12 Jan 2016 00:43:42 +0000 (+0000) Subject: [libFuzzer] extend the weak memcmp/strcmp/strncmp interceptors to receive the result... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=d89bfb65a8efc9791df9b6308cd57a10085fd32f;p=oota-llvm.git [libFuzzer] extend the weak memcmp/strcmp/strncmp interceptors to receive the result of the computations. With that, don't do any mutations if memcmp/etc returned 0 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257423 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Fuzzer/FuzzerTraceState.cpp b/lib/Fuzzer/FuzzerTraceState.cpp index 36fc6dcfd23..7ee20b353a7 100644 --- a/lib/Fuzzer/FuzzerTraceState.cpp +++ b/lib/Fuzzer/FuzzerTraceState.cpp @@ -539,16 +539,18 @@ void dfsan_weak_hook_strcmp(void *caller_pc, const char *s1, const char *s2, } void __sanitizer_weak_hook_memcmp(void *caller_pc, const void *s1, - const void *s2, size_t n) { + const void *s2, size_t n, int result) { if (!TS) return; + if (result == 0) return; // No reason to mutate. if (n <= 1) return; // Not interesting. TS->TraceMemcmpCallback(n, reinterpret_cast(s1), reinterpret_cast(s2)); } void __sanitizer_weak_hook_strncmp(void *caller_pc, const char *s1, - const char *s2, size_t n) { + const char *s2, size_t n, int result) { if (!TS) return; + if (result == 0) return; // No reason to mutate. size_t Len1 = fuzzer::InternalStrnlen(s1, n); size_t Len2 = fuzzer::InternalStrnlen(s2, n); n = std::min(n, Len1); @@ -559,8 +561,9 @@ void __sanitizer_weak_hook_strncmp(void *caller_pc, const char *s1, } void __sanitizer_weak_hook_strcmp(void *caller_pc, const char *s1, - const char *s2) { + const char *s2, int result) { if (!TS) return; + if (result == 0) return; // No reason to mutate. size_t Len1 = strlen(s1); size_t Len2 = strlen(s2); size_t N = std::min(Len1, Len2);