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 // Test strstr and strcasestr hooks. 6 #include <cstdint> 7 #include <cstdio> 8 #include <cstdlib> 9 #include <string.h> 10 #include <string> 11 12 // Windows does not have strcasestr and memmem, so we are not testing them. 13 #ifdef _WIN32 14 #define strcasestr strstr 15 #define memmem(a, b, c, d) true 16 #endif 17 18 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { 19 if (Size < 4) return 0; 20 std::string s(reinterpret_cast<const char*>(Data), Size); 21 if (strstr(s.c_str(), "FUZZ") && 22 strcasestr(s.c_str(), "aBcD") && 23 memmem(s.data(), s.size(), "kuku", 4) 24 ) { 25 fprintf(stderr, "BINGO\n"); 26 exit(1); 27 } 28 return 0; 29 } 30