diff options
| author | Kostya Serebryany <kcc@google.com> | 2015-05-08 21:45:19 +0000 |
|---|---|---|
| committer | Kostya Serebryany <kcc@google.com> | 2015-05-08 21:45:19 +0000 |
| commit | f3f3ed323acae3e4a6a558d8fa338c717ad5db58 (patch) | |
| tree | fd2fe12d73d4506519632eafcff36c945a1b6f57 /llvm/lib/Fuzzer/test/DFSanSimpleCmpTest.cpp | |
| parent | a7046002959f3e1fad47b028b51756084934934c (diff) | |
| download | bcm5719-llvm-f3f3ed323acae3e4a6a558d8fa338c717ad5db58.tar.gz bcm5719-llvm-f3f3ed323acae3e4a6a558d8fa338c717ad5db58.zip | |
[lib/Fuzzer] build tests that work well with dfsan also w/o dfsan
llvm-svn: 236909
Diffstat (limited to 'llvm/lib/Fuzzer/test/DFSanSimpleCmpTest.cpp')
| -rw-r--r-- | llvm/lib/Fuzzer/test/DFSanSimpleCmpTest.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/llvm/lib/Fuzzer/test/DFSanSimpleCmpTest.cpp b/llvm/lib/Fuzzer/test/DFSanSimpleCmpTest.cpp new file mode 100644 index 00000000000..ee378146dae --- /dev/null +++ b/llvm/lib/Fuzzer/test/DFSanSimpleCmpTest.cpp @@ -0,0 +1,30 @@ +// 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); + } +} |

