George Karpenkov | 10ab2ac | 2017-08-21 23:25:50 +0000 | [diff] [blame] | 1 | // This file is distributed under the University of Illinois Open Source |
| 2 | // License. See LICENSE.TXT for details. |
| 3 | |
| 4 | // Simple test for a fuzzer. Must find a specific string |
| 5 | // used in std::string operator ==. |
| 6 | #include <cstddef> |
| 7 | #include <cstdint> |
| 8 | #include <cstdlib> |
| 9 | #include <iostream> |
| 10 | #include <string> |
| 11 | |
| 12 | static volatile int Sink; |
| 13 | |
| 14 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { |
| 15 | std::string Str((const char*)Data, Size); |
| 16 | bool Eq = Str == "FooBar"; |
| 17 | Sink = Str == "123456"; // Try to confuse the fuzzer |
| 18 | if (Eq) { |
| 19 | std::cout << "BINGO; Found the target, exiting\n"; |
| 20 | std::cout.flush(); |
| 21 | abort(); |
| 22 | } |
| 23 | return 0; |
| 24 | } |
| 25 | |