diff options
author | Kostya Serebryany <kcc@google.com> | 2017-01-23 22:11:04 +0000 |
---|---|---|
committer | Kostya Serebryany <kcc@google.com> | 2017-01-23 22:11:04 +0000 |
commit | 6bdd8fc5b605371052184c5d4c69a4c189a913bc (patch) | |
tree | 1b3fe077910a803c1567888dc10a158e21df0a44 /llvm/lib/Fuzzer/test/CxxStringEqTest.cpp | |
parent | 014d9491ffd349d5488710564333deb99639dc16 (diff) | |
download | bcm5719-llvm-6bdd8fc5b605371052184c5d4c69a4c189a913bc.tar.gz bcm5719-llvm-6bdd8fc5b605371052184c5d4c69a4c189a913bc.zip |
[libFuzzer] make sure we use the feedback from std::string operator ==
llvm-svn: 292835
Diffstat (limited to 'llvm/lib/Fuzzer/test/CxxStringEqTest.cpp')
-rw-r--r-- | llvm/lib/Fuzzer/test/CxxStringEqTest.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/llvm/lib/Fuzzer/test/CxxStringEqTest.cpp b/llvm/lib/Fuzzer/test/CxxStringEqTest.cpp new file mode 100644 index 00000000000..9005ab8467b --- /dev/null +++ b/llvm/lib/Fuzzer/test/CxxStringEqTest.cpp @@ -0,0 +1,24 @@ +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. + +// Simple test for a fuzzer. Must find a specific string +// used in std::string operator ==. +#include <cstdint> +#include <cstdlib> +#include <cstddef> +#include <string> +#include <iostream> + +static volatile int Sink; + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { + std::string Str((const char*)Data, Size); + bool Eq = Str == "FooBar"; + Sink = Str == "123456"; // Try to confuse the fuzzer + if (Eq) { + std::cout << "BINGO; Found the target, exiting\n"; + abort(); + } + return 0; +} + |