diff options
| author | Kostya Serebryany <kcc@google.com> | 2016-01-12 00:43:42 +0000 |
|---|---|---|
| committer | Kostya Serebryany <kcc@google.com> | 2016-01-12 00:43:42 +0000 |
| commit | e3580956eafac63324ba4db80de28cd9a030981a (patch) | |
| tree | 1e14e1c8b282fdb38551cc5909b3e4b5c688df54 /llvm/lib/Fuzzer | |
| parent | 7087a51b131961527a419ecf17e757c24bb88929 (diff) | |
| download | bcm5719-llvm-e3580956eafac63324ba4db80de28cd9a030981a.tar.gz bcm5719-llvm-e3580956eafac63324ba4db80de28cd9a030981a.zip | |
[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
llvm-svn: 257423
Diffstat (limited to 'llvm/lib/Fuzzer')
| -rw-r--r-- | llvm/lib/Fuzzer/FuzzerTraceState.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/llvm/lib/Fuzzer/FuzzerTraceState.cpp b/llvm/lib/Fuzzer/FuzzerTraceState.cpp index 36fc6dcfd23..7ee20b353a7 100644 --- a/llvm/lib/Fuzzer/FuzzerTraceState.cpp +++ b/llvm/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<const uint8_t *>(s1), reinterpret_cast<const uint8_t *>(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); |

