]> granicus.if.org Git - llvm/commitdiff
[libFuzzer] increase the size of FixedWord from 27 to 64, see PR31950
authorKostya Serebryany <kcc@google.com>
Tue, 14 Feb 2017 23:02:37 +0000 (23:02 +0000)
committerKostya Serebryany <kcc@google.com>
Tue, 14 Feb 2017 23:02:37 +0000 (23:02 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295117 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Fuzzer/FuzzerDictionary.h
lib/Fuzzer/test/CMakeLists.txt
lib/Fuzzer/test/Memcmp64BytesTest.cpp [new file with mode: 0644]
lib/Fuzzer/test/fuzzer-traces-hooks.test

index f15ac930f2c53bab55501d5e31275fb57219bbcc..f5024b1aeeca78b8611d9cb877d67ab69e300934 100644 (file)
@@ -51,7 +51,7 @@ private:
   uint8_t Data[kMaxSize];
 };
 
-typedef FixedWord<27> Word; // 28 bytes.
+typedef FixedWord<64> Word;
 
 class DictionaryEntry {
  public:
index 890cbeef5e49ac411ab333ab50d8c32328ceca80..14d5f12f4e9245a573e9c1e90e982657421686f6 100644 (file)
@@ -90,6 +90,7 @@ set(Tests
   FourIndependentBranchesTest
   FullCoverageSetTest
   InitializeTest
+  Memcmp64BytesTest
   MemcmpTest
   LeakTest
   LeakTimeoutTest
diff --git a/lib/Fuzzer/test/Memcmp64BytesTest.cpp b/lib/Fuzzer/test/Memcmp64BytesTest.cpp
new file mode 100644 (file)
index 0000000..e81526b
--- /dev/null
@@ -0,0 +1,20 @@
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+
+// Simple test for a fuzzer. The fuzzer must find a particular string.
+#include <cassert>
+#include <cstring>
+#include <cstdint>
+#include <cstdio>
+#include <cstdlib>
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
+  const char kString64Bytes[] =
+      "123456789 123456789 123456789 123456789 123456789 123456789 1234";
+  assert(sizeof(kString64Bytes) == 65);
+  if (Size >= 64 && memcmp(Data, kString64Bytes, 64) == 0) {
+    fprintf(stderr, "BINGO\n");
+    exit(1);
+  }
+  return 0;
+}
index 14f4f8bfbb9d0d8b15157f72bda512aa686b9891..ff1bddb1e4274ba2473a92f5d714d1a1031288e5 100644 (file)
@@ -9,6 +9,8 @@ RUN: not LLVMFuzzer-StrncmpTest              -seed=1 -runs=2000000   2>&1 | File
 RUN: not LLVMFuzzer-StrcmpTest               -seed=1 -runs=2000000   2>&1 | FileCheck %s
 RUN: not LLVMFuzzer-StrstrTest               -seed=1 -runs=2000000   2>&1 | FileCheck %s
 
+RUN: not LLVMFuzzer-Memcmp64BytesTest        -seed=1 -runs=10000   2>&1 | FileCheck %s
+
 RUN: LLVMFuzzer-RepeatedMemcmp -seed=11 -runs=100000 2>&1 | FileCheck %s --check-prefix=RECOMMENDED_DICT
 RECOMMENDED_DICT:###### Recommended dictionary. ######
 RECOMMENDED_DICT-DAG: "foo"