blob: cd7292bd006c8388c64e0f0018356b0596b2a4a8 [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 Serebryany7d211662015-09-04 00:12:11 +00004// Simple test for a fuzzer.
5// The fuzzer must find a string based on dictionary words:
6// "Elvis"
7// "Presley"
8#include <cstdint>
9#include <cstdlib>
10#include <cstddef>
11#include <cstring>
12#include <iostream>
13
14static volatile int Zero = 0;
15
Kostya Serebryany20bb5e72015-10-02 23:34:06 +000016extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
Kostya Serebryany7d211662015-09-04 00:12:11 +000017 const char *Expected = "ElvisPresley";
Kostya Serebryany20bb5e72015-10-02 23:34:06 +000018 if (Size < strlen(Expected)) return 0;
Kostya Serebryany7d211662015-09-04 00:12:11 +000019 size_t Match = 0;
20 for (size_t i = 0; Expected[i]; i++)
21 if (Expected[i] + Zero == Data[i])
22 Match++;
23 if (Match == strlen(Expected)) {
24 std::cout << "BINGO; Found the target, exiting\n";
25 exit(1);
26 }
Kostya Serebryany20bb5e72015-10-02 23:34:06 +000027 return 0;
Kostya Serebryany7d211662015-09-04 00:12:11 +000028}
29