# for the Fuzzer lib)
set(CMAKE_CXX_FLAGS_RELEASE "${LIBFUZZER_FLAGS_BASE} -O0 -fsanitize-coverage=edge,indirect-calls")
+set(DFSanTests
+ DFSanMemcmpTest
+ DFSanSimpleCmpTest
+ )
+
set(Tests
CounterTest
CxxTokensTest
NullDerefTest
SimpleTest
TimeoutTest
+ ${DFSanTests}
)
-set(DFSanTests
- DFSanMemcmpTest
- DFSanSimpleCmpTest
- )
set(TestBinaries)
add_subdirectory(dfsan)
foreach(Test ${DFSanTests})
- set(TestBinaries ${TestBinaries} LLVMFuzzer-${Test})
+ set(TestBinaries ${TestBinaries} LLVMFuzzer-${Test}-DFSan)
endforeach()
--- /dev/null
+// Simple test for a fuzzer. The fuzzer must find a particular string.
+#include <cstring>
+#include <cstdint>
+#include <cstdio>
+#include <cstdlib>
+
+extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
+ if (Size >= 8 && memcmp(Data, "01234567", 8) == 0) {
+ fprintf(stderr, "BINGO\n");
+ exit(1);
+ }
+}
--- /dev/null
+// Simple test for a fuzzer. The fuzzer must find several narrow ranges.
+#include <cstdint>
+#include <cstdlib>
+#include <cstring>
+#include <cstdio>
+
+extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
+ if (Size < 14) return;
+ uint64_t x = 0;
+ int64_t y = 0;
+ int z = 0;
+ unsigned short a = 0;
+ memcpy(&x, Data, 8);
+ memcpy(&y, Data + Size - 8, 8);
+ memcpy(&z, Data + Size / 2, sizeof(z));
+ memcpy(&a, Data + Size / 2 + 4, sizeof(a));
+
+ if (x > 1234567890 &&
+ x < 1234567895 &&
+ y >= 987654321 &&
+ y <= 987654325 &&
+ z < -10000 &&
+ z >= -10005 &&
+ z != -10003 &&
+ a == 4242) {
+ fprintf(stderr, "BINGO; Found the target: size %zd (%zd, %zd, %d, %d), exiting.\n",
+ Size, x, y, z, a);
+ exit(1);
+ }
+}
"${LIBFUZZER_FLAGS_BASE} -O0 -fno-sanitize=all -fsanitize=dataflow")
foreach(Test ${DFSanTests})
- add_executable(LLVMFuzzer-${Test}
- ${Test}.cpp
+ add_executable(LLVMFuzzer-${Test}-DFSan
+ ../${Test}.cpp
)
- target_link_libraries(LLVMFuzzer-${Test}
+ target_link_libraries(LLVMFuzzer-${Test}-DFSan
LLVMFuzzer
)
endforeach()
+++ /dev/null
-// Simple test for a fuzzer. The fuzzer must find a particular string.
-#include <cstring>
-#include <cstdint>
-#include <cstdio>
-#include <cstdlib>
-
-extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
- if (Size >= 8 && memcmp(Data, "01234567", 8) == 0) {
- fprintf(stderr, "BINGO\n");
- exit(1);
- }
-}
+++ /dev/null
-// Simple test for a fuzzer. The fuzzer must find several narrow ranges.
-#include <cstdint>
-#include <cstdlib>
-#include <cstring>
-#include <cstdio>
-
-extern "C" void LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
- if (Size < 14) return;
- uint64_t x = 0;
- int64_t y = 0;
- int z = 0;
- unsigned short a = 0;
- memcpy(&x, Data, 8);
- memcpy(&y, Data + Size - 8, 8);
- memcpy(&z, Data + Size / 2, sizeof(z));
- memcpy(&a, Data + Size / 2 + 4, sizeof(a));
-
- if (x > 1234567890 &&
- x < 1234567895 &&
- y >= 987654321 &&
- y <= 987654325 &&
- z < -10000 &&
- z >= -10005 &&
- z != -10003 &&
- a == 4242) {
- fprintf(stderr, "BINGO; Found the target: size %zd (%zd, %zd, %d, %d), exiting.\n",
- Size, x, y, z, a);
- exit(1);
- }
-}
RUN: not ./LLVMFuzzer-CounterTest -use_counters=1 -max_len=6 -seed=1 -timeout=15 2>&1 | FileCheck %s
-RUN: not ./LLVMFuzzer-DFSanSimpleCmpTest -seed=1 -runs=1000000 -timeout=5 2>&1 | FileCheck %s
+RUN: not ./LLVMFuzzer-DFSanSimpleCmpTest-DFSan -seed=1 -runs=1000000 -timeout=5 2>&1 | FileCheck %s
-RUN: not ./LLVMFuzzer-DFSanMemcmpTest -seed=1 -runs=100 -timeout=5 2>&1 | FileCheck %s
+RUN: not ./LLVMFuzzer-DFSanMemcmpTest-DFSan -seed=1 -runs=100 -timeout=5 2>&1 | FileCheck %s
RUN: not ./LLVMFuzzer-CxxTokensTest -seed=1 -timeout=15 -tokens=%S/../cxx_fuzzer_tokens.txt 2>&1 | FileCheck %s