blob: 3873b710ba7f607796ca75769f0555c6647ac073 [file] [log] [blame]
Kostya Serebryanyd790eff2018-05-10 02:02:41 +00001// 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
12const size_t N = 2048;
13typedef const uint8_t *IN;
14
Kostya Serebryanye9c6f062018-05-16 23:26:37 +000015extern "C" {
Kostya Serebryanyd790eff2018-05-10 02:02:41 +000016__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 Serebryanye9c6f062018-05-16 23:26:37 +000031} // extern "C"
32
Kostya Serebryanyd790eff2018-05-10 02:02:41 +000033extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
34 if (Size < N) return 0;
35 fA((IN)Data);
36 return 0;
37}