[llvm] r309889 - [libFuzzer tests] Use substring comparison in libFuzzer tests

George Karpenkov via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 2 14:38:51 PDT 2017


Author: george.karpenkov
Date: Wed Aug  2 14:38:50 2017
New Revision: 309889

URL: http://llvm.org/viewvc/llvm-project?rev=309889&view=rev
Log:
[libFuzzer tests] Use substring comparison in libFuzzer tests

LIT launches executables with absolute, and not relative, path.
strncmp would try to do exact comparison and fail.

Differential Revision: https://reviews.llvm.org/D36242

Modified:
    llvm/trunk/lib/Fuzzer/test/InitializeTest.cpp

Modified: llvm/trunk/lib/Fuzzer/test/InitializeTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Fuzzer/test/InitializeTest.cpp?rev=309889&r1=309888&r2=309889&view=diff
==============================================================================
--- llvm/trunk/lib/Fuzzer/test/InitializeTest.cpp (original)
+++ llvm/trunk/lib/Fuzzer/test/InitializeTest.cpp Wed Aug  2 14:38:50 2017
@@ -20,7 +20,7 @@ extern "C" int LLVMFuzzerInitialize(int
 
 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
   if (Size == strlen(argv0) &&
-      !strncmp(reinterpret_cast<const char *>(Data), argv0, Size)) {
+      !strnstr(reinterpret_cast<const char *>(Data), argv0, Size)) {
     fprintf(stderr, "BINGO %s\n", argv0);
     exit(1);
   }




More information about the llvm-commits mailing list