1*97c675d3SNico Weber // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
2*97c675d3SNico Weber // See https://llvm.org/LICENSE.txt for license information.
3*97c675d3SNico Weber // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4*97c675d3SNico Weber 
5*97c675d3SNico Weber // Simple test for a fuzzer. The fuzzer must find the string "Hi!".
6*97c675d3SNico Weber #include <cstddef>
7*97c675d3SNico Weber #include <cstdint>
8*97c675d3SNico Weber #include <cstdlib>
9*97c675d3SNico Weber #include <cstdio>
10*97c675d3SNico Weber 
11*97c675d3SNico Weber static volatile int Sink;
12*97c675d3SNico Weber static volatile int *Null = 0;
13*97c675d3SNico Weber 
LLVMFuzzerTestOneInput(const uint8_t * Data,size_t Size)14*97c675d3SNico Weber extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
15*97c675d3SNico Weber   if (Size > 0 && Data[0] == 'H') {
16*97c675d3SNico Weber     Sink = 1;
17*97c675d3SNico Weber     if (Size > 1 && Data[1] == 'i') {
18*97c675d3SNico Weber       Sink = 2;
19*97c675d3SNico Weber       if (Size > 2 && Data[2] == '!') {
20*97c675d3SNico Weber         printf("Found the target, dereferencing NULL\n");
21*97c675d3SNico Weber         *Null = 1;
22*97c675d3SNico Weber       }
23*97c675d3SNico Weber     }
24*97c675d3SNico Weber   }
25*97c675d3SNico Weber   return 0;
26*97c675d3SNico Weber }
27*97c675d3SNico Weber 
28