]>
Commit | Line | Data |
---|---|---|
1e59de90 TL |
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. | |
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 | ||
16 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { | |
17 | const char *Expected = "ElvisPresley"; | |
18 | if (Size < strlen(Expected)) return 0; | |
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 | } | |
27 | return 0; | |
28 | } | |
29 |