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. 5 // The fuzzer must find a string based on dictionary words: 6 // "Elvis" 7 // "Presley" 8 #include <cstddef> 9 #include <cstdint> 10 #include <cstdlib> 11 #include <cstring> 12 #include <iostream> 13 #include <ostream> 14 15 static volatile int Zero = 0; 16 17 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { 18 const char *Expected = "ElvisPresley"; 19 if (Size < strlen(Expected)) return 0; 20 size_t Match = 0; 21 for (size_t i = 0; Expected[i]; i++) 22 if (Expected[i] + Zero == Data[i]) 23 Match++; 24 if (Match == strlen(Expected)) { 25 std::cout << "BINGO; Found the target, exiting\n" << std::flush; 26 exit(1); 27 } 28 return 0; 29 } 30 31