1c5f01b2fSopenharmony_ci// This file is distributed under the University of Illinois Open Source 2c5f01b2fSopenharmony_ci// License. See LICENSE.TXT for details. 3c5f01b2fSopenharmony_ci 4c5f01b2fSopenharmony_ci// Break through a series of strcmp. 5c5f01b2fSopenharmony_ci#include <cstring> 6c5f01b2fSopenharmony_ci#include <cstdint> 7c5f01b2fSopenharmony_ci#include <cstdio> 8c5f01b2fSopenharmony_ci#include <cstdlib> 9c5f01b2fSopenharmony_ci#include <cassert> 10c5f01b2fSopenharmony_ci 11c5f01b2fSopenharmony_cibool Eq(const uint8_t *Data, size_t Size, const char *Str) { 12c5f01b2fSopenharmony_ci char Buff[1024]; 13c5f01b2fSopenharmony_ci size_t Len = strlen(Str); 14c5f01b2fSopenharmony_ci if (Size < Len) return false; 15c5f01b2fSopenharmony_ci if (Len >= sizeof(Buff)) return false; 16c5f01b2fSopenharmony_ci memcpy(Buff, (char*)Data, Len); 17c5f01b2fSopenharmony_ci Buff[Len] = 0; 18c5f01b2fSopenharmony_ci int res = strcmp(Buff, Str); 19c5f01b2fSopenharmony_ci return res == 0; 20c5f01b2fSopenharmony_ci} 21c5f01b2fSopenharmony_ci 22c5f01b2fSopenharmony_ciextern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { 23c5f01b2fSopenharmony_ci if (Eq(Data, Size, "ABC") && 24c5f01b2fSopenharmony_ci Size >= 3 && Eq(Data + 3, Size - 3, "QWER") && 25c5f01b2fSopenharmony_ci Size >= 7 && Eq(Data + 7, Size - 7, "ZXCVN") && 26c5f01b2fSopenharmony_ci Size >= 14 && Data[13] == 42 27c5f01b2fSopenharmony_ci ) { 28c5f01b2fSopenharmony_ci fprintf(stderr, "BINGO\n"); 29c5f01b2fSopenharmony_ci exit(1); 30c5f01b2fSopenharmony_ci } 31c5f01b2fSopenharmony_ci return 0; 32c5f01b2fSopenharmony_ci} 33