blob: 55344d75e0b1f765aac0a34e24ca14301d16f700 [file] [log] [blame]
Kostya Serebryanyb74ba422015-07-30 02:33:45 +00001// Simple test for a fuzzer. The fuzzer must find a particular string.
2#include <cstring>
3#include <cstdint>
4#include <cstdio>
5#include <cstdlib>
6
Kostya Serebryanyc9dc96b2015-07-30 21:22:22 +00007static volatile int sink;
8
Kostya Serebryany20bb5e72015-10-02 23:34:06 +00009extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
Kostya Serebryanyb74ba422015-07-30 02:33:45 +000010 // TODO: check other sizes.
11 char *S = (char*)Data;
Kostya Serebryanyc9dc96b2015-07-30 21:22:22 +000012 if (Size >= 8 && strncmp(S, "123", 8))
13 sink = 1;
Kostya Serebryanyb74ba422015-07-30 02:33:45 +000014 if (Size >= 8 && strncmp(S, "01234567", 8) == 0) {
15 if (Size >= 12 && strncmp(S + 8, "ABCD", 4) == 0) {
16 if (Size >= 14 && strncmp(S + 12, "XY", 2) == 0) {
17 if (Size >= 16 && strncmp(S + 14, "KLM", 3) == 0) {
18 fprintf(stderr, "BINGO\n");
19 exit(1);
20 }
21 }
22 }
23 }
Kostya Serebryany20bb5e72015-10-02 23:34:06 +000024 return 0;
Kostya Serebryanyb74ba422015-07-30 02:33:45 +000025}