| 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 | // Break through a series of strcmp. |
| 6 | #include <cassert> |
| 7 | #include <cstdint> |
| 8 | #include <cstdio> |
| 9 | #include <cstdlib> |
| 10 | #include <cstring> |
| 11 | |
| 12 | bool Eq(const uint8_t *Data, size_t Size, const char *Str) { |
| 13 | char Buff[1024]; |
| 14 | size_t Len = strlen(s: Str); |
| 15 | if (Size < Len) return false; |
| 16 | if (Len >= sizeof(Buff)) return false; |
| 17 | memcpy(dest: Buff, src: (const char*)Data, n: Len); |
| 18 | Buff[Len] = 0; |
| 19 | int res = strcmp(s1: Buff, s2: Str); |
| 20 | return res == 0; |
| 21 | } |
| 22 | |
| 23 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { |
| 24 | if (Eq(Data, Size, Str: "ABC" ) && |
| 25 | Size >= 3 && Eq(Data: Data + 3, Size: Size - 3, Str: "QWER" ) && |
| 26 | Size >= 7 && Eq(Data: Data + 7, Size: Size - 7, Str: "ZXCVN" )) { |
| 27 | fprintf(stderr, format: "BINGO\n" ); |
| 28 | exit(status: 1); |
| 29 | } |
| 30 | return 0; |
| 31 | } |
| 32 | |