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// Simple test for a fuzzer. The fuzzer must find a particular string. 5c5f01b2fSopenharmony_ci#include <cstring> 6c5f01b2fSopenharmony_ci#include <cstdint> 7c5f01b2fSopenharmony_ci#include <cstdio> 8c5f01b2fSopenharmony_ci#include <cstdlib> 9c5f01b2fSopenharmony_ci 10c5f01b2fSopenharmony_ciextern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { 11c5f01b2fSopenharmony_ci // TODO: check other sizes. 12c5f01b2fSopenharmony_ci if (Size >= 8 && memcmp(Data, "01234567", 8) == 0) { 13c5f01b2fSopenharmony_ci if (Size >= 12 && memcmp(Data + 8, "ABCD", 4) == 0) { 14c5f01b2fSopenharmony_ci if (Size >= 14 && memcmp(Data + 12, "XY", 2) == 0) { 15c5f01b2fSopenharmony_ci if (Size >= 17 && memcmp(Data + 14, "KLM", 3) == 0) { 16c5f01b2fSopenharmony_ci if (Size >= 27 && memcmp(Data + 17, "ABCDE-GHIJ", 10) == 0){ 17c5f01b2fSopenharmony_ci fprintf(stderr, "BINGO %zd\n", Size); 18c5f01b2fSopenharmony_ci for (size_t i = 0; i < Size; i++) { 19c5f01b2fSopenharmony_ci uint8_t C = Data[i]; 20c5f01b2fSopenharmony_ci if (C >= 32 && C < 127) 21c5f01b2fSopenharmony_ci fprintf(stderr, "%c", C); 22c5f01b2fSopenharmony_ci } 23c5f01b2fSopenharmony_ci fprintf(stderr, "\n"); 24c5f01b2fSopenharmony_ci exit(1); 25c5f01b2fSopenharmony_ci } 26c5f01b2fSopenharmony_ci } 27c5f01b2fSopenharmony_ci } 28c5f01b2fSopenharmony_ci } 29c5f01b2fSopenharmony_ci } 30c5f01b2fSopenharmony_ci return 0; 31c5f01b2fSopenharmony_ci} 32