diff options
author | Kostya Serebryany <kcc@google.com> | 2016-01-14 02:36:44 +0000 |
---|---|---|
committer | Kostya Serebryany <kcc@google.com> | 2016-01-14 02:36:44 +0000 |
commit | 4b35874b2a9e8efc8e3123726bc611030d382ecf (patch) | |
tree | 3c130f1077fc9aa46e9a59eb6a0c8846f4535303 /llvm/lib/Fuzzer/test/RepeatedMemcmp.cpp | |
parent | dfc77357a0eb17412e284b4d0bad37bbf2c39c2e (diff) | |
download | bcm5719-llvm-4b35874b2a9e8efc8e3123726bc611030d382ecf.tar.gz bcm5719-llvm-4b35874b2a9e8efc8e3123726bc611030d382ecf.zip |
[libFuzzer] suggest a dictionary to the user of some of the trace-based dictionary entries were successful
llvm-svn: 257736
Diffstat (limited to 'llvm/lib/Fuzzer/test/RepeatedMemcmp.cpp')
-rw-r--r-- | llvm/lib/Fuzzer/test/RepeatedMemcmp.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/llvm/lib/Fuzzer/test/RepeatedMemcmp.cpp b/llvm/lib/Fuzzer/test/RepeatedMemcmp.cpp new file mode 100644 index 00000000000..cb5e130003b --- /dev/null +++ b/llvm/lib/Fuzzer/test/RepeatedMemcmp.cpp @@ -0,0 +1,19 @@ + +#include <cstring> +#include <cstdint> +#include <cstdio> +#include <cstdlib> + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { + int Matches = 0; + for (size_t i = 0; i + 2 < Size; i += 3) { + const char *Pat = i % 2 ? "foo" : "bar"; + if (!memcmp(Data + i, Pat, 3)) + Matches++; + } + if (Matches > 20) { + fprintf(stderr, "BINGO!\n"); + exit(1); + } + return 0; +} |