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 | // Test that we can find the minimal item in the corpus (3 bytes: "FUZ"). |
| 5 | #include <cstddef> |
| 6 | #include <cstdint> |
| 7 | #include <cstdio> |
| 8 | #include <cstdlib> |
| 9 | #include <cstring> |
| 10 | |
| 11 | static volatile int Sink; |
| 12 | |
| 13 | void Foo() { |
| 14 | Sink++; |
| 15 | } |
| 16 | |
| 17 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { |
| 18 | int8_t Ids[256]; |
| 19 | memset(Ids, -1, sizeof(Ids)); |
| 20 | for (size_t i = 0; i < Size; i++) |
| 21 | if (Ids[Data[i]] == -1) |
| 22 | Ids[Data[i]] = i; |
| 23 | int F = Ids[(unsigned char)'F']; |
| 24 | int U = Ids[(unsigned char)'U']; |
| 25 | int Z = Ids[(unsigned char)'Z']; |
| 26 | if (F >= 0 && U > F && Z > U) { |
| 27 | Foo(); |
| 28 | } |
| 29 | return 0; |
| 30 | } |
| 31 | |