1 // This file is distributed under the University of Illinois Open Source 2 // License. See LICENSE.TXT for details. 3 4 // Test strstr and strcasestr hooks. 5 #include <cstdint> 6 #include <cstdio> 7 #include <cstdlib> 8 #include <string.h> 9 #include <string> 10 11 // Windows does not have strcasestr and memmem, so we are not testing them. 12 #ifdef _WIN32 13 #define strcasestr strstr 14 #define memmem(a, b, c, d) true 15 #endif 16 17 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { 18 if (Size < 4) return 0; 19 std::string s(reinterpret_cast<const char*>(Data), Size); 20 if (strstr(s.c_str(), "FUZZ") && 21 strcasestr(s.c_str(), "aBcD") && 22 memmem(s.data(), s.size(), "kuku", 4) 23 ) { 24 fprintf(stderr, "BINGO\n"); 25 exit(1); 26 } 27 return 0; 28 } 29