Kostya Serebryany | c135b55 | 2016-07-15 23:27:19 +0000 | [diff] [blame] | 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 <string> |
| 6 | #include <string.h> |
| 7 | #include <cstdint> |
| 8 | #include <cstdio> |
| 9 | #include <cstdlib> |
| 10 | |
| 11 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { |
Kostya Serebryany | 6b08be9 | 2016-07-19 18:29:06 +0000 | [diff] [blame] | 12 | if (Size < 4) return 0; |
Kostya Serebryany | c135b55 | 2016-07-15 23:27:19 +0000 | [diff] [blame] | 13 | std::string s(reinterpret_cast<const char*>(Data), Size); |
Kostya Serebryany | 6b08be9 | 2016-07-19 18:29:06 +0000 | [diff] [blame] | 14 | if (strstr(s.c_str(), "FUZZ") && |
| 15 | strcasestr(s.c_str(), "aBcD") && |
| 16 | memmem(s.data(), s.size(), "kuku", 4) |
| 17 | ) { |
Kostya Serebryany | c135b55 | 2016-07-15 23:27:19 +0000 | [diff] [blame] | 18 | fprintf(stderr, "BINGO\n"); |
| 19 | exit(1); |
| 20 | } |
| 21 | return 0; |
| 22 | } |