1 // This file is distributed under the University of Illinois Open Source 2 // License. See LICENSE.TXT for details. 3 4 // Simple test for a fuzzer. The fuzzer must find repeated bytes. 5 #include <assert.h> 6 #include <cstdint> 7 #include <cstdlib> 8 #include <cstddef> 9 #include <iostream> 10 LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)11extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { 12 assert(Data); 13 // Looking for AAAAAAAAAAAAAAAAAAAAAA or some such. 14 size_t CurA = 0, MaxA = 0; 15 for (size_t i = 0; i < Size; i++) { 16 // Make sure there are no conditionals in the loop so that 17 // coverage can't help the fuzzer. 18 int EQ = Data[i] == 'A'; 19 CurA = EQ * (CurA + 1); 20 int GT = CurA > MaxA; 21 MaxA = GT * CurA + (!GT) * MaxA; 22 } 23 if (MaxA >= 20) { 24 std::cout << "BINGO; Found the target (Max: " << MaxA << "), exiting\n"; 25 exit(0); 26 } 27 return 0; 28 } 29 30