Mike Aizatsky | f13cbee | 2016-04-01 18:38:58 +0000 | [diff] [blame^] | 1 | // This file is distributed under the University of Illinois Open Source |
| 2 | // License. See LICENSE.TXT for details. |
| 3 | |
Kostya Serebryany | 7d21166 | 2015-09-04 00:12:11 +0000 | [diff] [blame] | 4 | // Simple test for a fuzzer. |
| 5 | // The fuzzer must find a string based on dictionary words: |
| 6 | // "Elvis" |
| 7 | // "Presley" |
| 8 | #include <cstdint> |
| 9 | #include <cstdlib> |
| 10 | #include <cstddef> |
| 11 | #include <cstring> |
| 12 | #include <iostream> |
| 13 | |
| 14 | static volatile int Zero = 0; |
| 15 | |
Kostya Serebryany | 20bb5e7 | 2015-10-02 23:34:06 +0000 | [diff] [blame] | 16 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { |
Kostya Serebryany | 7d21166 | 2015-09-04 00:12:11 +0000 | [diff] [blame] | 17 | const char *Expected = "ElvisPresley"; |
Kostya Serebryany | 20bb5e7 | 2015-10-02 23:34:06 +0000 | [diff] [blame] | 18 | if (Size < strlen(Expected)) return 0; |
Kostya Serebryany | 7d21166 | 2015-09-04 00:12:11 +0000 | [diff] [blame] | 19 | size_t Match = 0; |
| 20 | for (size_t i = 0; Expected[i]; i++) |
| 21 | if (Expected[i] + Zero == Data[i]) |
| 22 | Match++; |
| 23 | if (Match == strlen(Expected)) { |
| 24 | std::cout << "BINGO; Found the target, exiting\n"; |
| 25 | exit(1); |
| 26 | } |
Kostya Serebryany | 20bb5e7 | 2015-10-02 23:34:06 +0000 | [diff] [blame] | 27 | return 0; |
Kostya Serebryany | 7d21166 | 2015-09-04 00:12:11 +0000 | [diff] [blame] | 28 | } |
| 29 | |