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 <cstddef> 7 #include <cstdint> 8 #include <cstdlib> 9 #include <iostream> 10 #include <ostream> 11 12 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { 13 assert(Data); 14 // Looking for AAAAAAAAAAAAAAAAAAAAAA or some such. 15 size_t CurA = 0, MaxA = 0; 16 for (size_t i = 0; i < Size; i++) { 17 // Make sure there are no conditionals in the loop so that 18 // coverage can't help the fuzzer. 19 int EQ = Data[i] == 'A'; 20 CurA = EQ * (CurA + 1); 21 int GT = CurA > MaxA; 22 MaxA = GT * CurA + (!GT) * MaxA; 23 } 24 if (MaxA >= 20) { 25 std::cout << "BINGO; Found the target (Max: " << MaxA << "), exiting\n" 26 << std::flush; 27 exit(0); 28 } 29 return 0; 30 } 31 32