blob: 5ffd011dcdfff834203c148a192bd0514cf700cc [file] [log] [blame]
Mike Aizatskyf13cbee2016-04-01 18:38:58 +00001// This file is distributed under the University of Illinois Open Source
2// License. See LICENSE.TXT for details.
3
Kostya Serebryanyb74ba422015-07-30 02:33:45 +00004// Simple test for a fuzzer. The fuzzer must find a particular string.
5#include <cstring>
6#include <cstdint>
7#include <cstdio>
8#include <cstdlib>
9
Kostya Serebryanyc9dc96b2015-07-30 21:22:22 +000010static volatile int sink;
11
Kostya Serebryany20bb5e72015-10-02 23:34:06 +000012extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
Kostya Serebryanyb74ba422015-07-30 02:33:45 +000013 // TODO: check other sizes.
14 char *S = (char*)Data;
Kostya Serebryanyc9dc96b2015-07-30 21:22:22 +000015 if (Size >= 8 && strncmp(S, "123", 8))
16 sink = 1;
Kostya Serebryanyb74ba422015-07-30 02:33:45 +000017 if (Size >= 8 && strncmp(S, "01234567", 8) == 0) {
18 if (Size >= 12 && strncmp(S + 8, "ABCD", 4) == 0) {
19 if (Size >= 14 && strncmp(S + 12, "XY", 2) == 0) {
Kostya Serebryanyd46a59f2016-08-16 19:33:51 +000020 if (Size >= 17 && strncmp(S + 14, "KLM", 3) == 0) {
Kostya Serebryanyb74ba422015-07-30 02:33:45 +000021 fprintf(stderr, "BINGO\n");
22 exit(1);
23 }
24 }
25 }
26 }
Kostya Serebryany20bb5e72015-10-02 23:34:06 +000027 return 0;
Kostya Serebryanyb74ba422015-07-30 02:33:45 +000028}