Kostya Serebryany | d790eff | 2018-05-10 02:02:41 +0000 | [diff] [blame] | 1 | // This file is distributed under the University of Illinois Open Source |
| 2 | // License. See LICENSE.TXT for details. |
| 3 | |
| 4 | // Find ABCxxFxUxZxxx... (2048+ bytes, 'x' is any byte) |
| 5 | #include <assert.h> |
| 6 | #include <cstddef> |
| 7 | #include <cstdint> |
| 8 | #include <cstdlib> |
| 9 | #include <cstring> |
| 10 | #include <cstdio> |
| 11 | |
| 12 | const size_t N = 2048; |
| 13 | typedef const uint8_t *IN; |
| 14 | |
Kostya Serebryany | e9c6f06 | 2018-05-16 23:26:37 +0000 | [diff] [blame^] | 15 | extern "C" { |
Kostya Serebryany | d790eff | 2018-05-10 02:02:41 +0000 | [diff] [blame] | 16 | __attribute__((noinline)) void bad() { |
| 17 | fprintf(stderr, "BINGO\n"); |
| 18 | abort(); |
| 19 | } |
| 20 | |
| 21 | __attribute__((noinline)) void f0(IN in) { |
| 22 | uint32_t x = in[5] + 251 * in[7] + 251 * 251 * in[9]; |
| 23 | if (x == 'F' + 251 * 'U' + 251 * 251 * 'Z') |
| 24 | bad(); |
| 25 | } |
| 26 | |
| 27 | __attribute__((noinline)) void fC(IN in) { if (in[2] == 'C') f0(in); } |
| 28 | __attribute__((noinline)) void fB(IN in) { if (in[1] == 'B') fC(in); } |
| 29 | __attribute__((noinline)) void fA(IN in) { if (in[0] == 'A') fB(in); } |
| 30 | |
Kostya Serebryany | e9c6f06 | 2018-05-16 23:26:37 +0000 | [diff] [blame^] | 31 | } // extern "C" |
| 32 | |
Kostya Serebryany | d790eff | 2018-05-10 02:02:41 +0000 | [diff] [blame] | 33 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { |
| 34 | if (Size < N) return 0; |
| 35 | fA((IN)Data); |
| 36 | return 0; |
| 37 | } |