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