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// Test that we can find the minimal item in the corpus (3 bytes: "FUZ"). 5c5f01b2fSopenharmony_ci#include <cstdint> 6c5f01b2fSopenharmony_ci#include <cstdlib> 7c5f01b2fSopenharmony_ci#include <cstddef> 8c5f01b2fSopenharmony_ci#include <cstring> 9c5f01b2fSopenharmony_ci#include <cstdio> 10c5f01b2fSopenharmony_ci 11c5f01b2fSopenharmony_cistatic volatile int Sink; 12c5f01b2fSopenharmony_ci 13c5f01b2fSopenharmony_ciextern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { 14c5f01b2fSopenharmony_ci int8_t Ids[256]; 15c5f01b2fSopenharmony_ci memset(Ids, -1, sizeof(Ids)); 16c5f01b2fSopenharmony_ci for (size_t i = 0; i < Size; i++) 17c5f01b2fSopenharmony_ci if (Ids[Data[i]] == -1) 18c5f01b2fSopenharmony_ci Ids[Data[i]] = i; 19c5f01b2fSopenharmony_ci int F = Ids[(unsigned char)'F']; 20c5f01b2fSopenharmony_ci int U = Ids[(unsigned char)'U']; 21c5f01b2fSopenharmony_ci int Z = Ids[(unsigned char)'Z']; 22c5f01b2fSopenharmony_ci if (F >= 0 && U > F && Z > U) { 23c5f01b2fSopenharmony_ci Sink++; 24c5f01b2fSopenharmony_ci //fprintf(stderr, "IDS: %d %d %d\n", F, U, Z); 25c5f01b2fSopenharmony_ci } 26c5f01b2fSopenharmony_ci return 0; 27c5f01b2fSopenharmony_ci} 28c5f01b2fSopenharmony_ci 29