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 // Simple test for a fuzzer. 6 // Needs to find a string "FUZZxxxxxxxxxxxxMxxE", where 'x' is any byte. 7 #include <assert.h> 8 #include <cstddef> 9 #include <cstdint> 10 #include <cstdlib> 11 #include <cstdio> 12 13 extern "C" bool Func1(const uint8_t *Data, size_t Size); 14 extern "C" bool Func2(const uint8_t *Data, size_t Size); 15 16 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { 17 if (Size >= 20 18 && Data[0] == 'F' 19 && Data[1] == 'U' 20 && Data[2] == 'Z' 21 && Data[3] == 'Z' 22 && Func1(Data, Size) 23 && Func2(Data, Size)) { 24 fprintf(stderr, "BINGO\n"); 25 abort(); 26 } 27 return 0; 28 } 29 30 extern "C" 31 __attribute__((noinline)) 32 bool Func1(const uint8_t *Data, size_t Size) { 33 // assumes Size >= 5, doesn't check it. 34 return Data[16] == 'M'; 35 } 36 37 extern "C" 38 __attribute__((noinline)) 39 bool Func2(const uint8_t *Data, size_t Size) { 40 return Size >= 20 && Data[19] == 'E'; 41 } 42 43 44