1 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
2 // See https://llvm.org/LICENSE.txt for license information.
3 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4 
5 // Find "FUZZME", the target has 3 different functions.
6 #include <assert.h>
7 #include <cstddef>
8 #include <cstdint>
9 #include <cstdlib>
10 #include <cstdio>
11 
12 extern "C"
13 __attribute__((noinline))
14 bool Func1(const uint8_t *Data, size_t Size) {
15   // assumes Size >= 5, doesn't check it.
16   return Data[4] == 'M';
17 }
18 
19 extern "C"
20 __attribute__((noinline))
21 bool Func2(const uint8_t *Data, size_t Size) {
22   return Size >= 6 && Data[5] == 'E';
23 }
24 
25 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
26   if (Size >= 5
27       && Data[0] == 'F'
28       && Data[1] == 'U'
29       && Data[2] == 'Z'
30       && Data[3] == 'Z'
31       && Func1(Data, Size)
32       && Func2(Data, Size)) {
33         fprintf(stderr, "BINGO\n");
34         abort();
35   }
36   return 0;
37 }
38