blob: 924851c5ad536d8d7f8d7d43d231cf746359b9df [file] [log] [blame]
George Karpenkov10ab2ac2017-08-21 23:25:50 +00001// This file is distributed under the University of Illinois Open Source
2// License. See LICENSE.TXT for details.
3
4// Simple test for a fuzzer. Must find a specific string
5// used in std::string operator ==.
6#include <cstddef>
7#include <cstdint>
8#include <cstdlib>
9#include <iostream>
10#include <string>
11
12static volatile int Sink;
13
14extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
15 std::string Str((const char*)Data, Size);
16 bool Eq = Str == "FooBar";
17 Sink = Str == "123456"; // Try to confuse the fuzzer
18 if (Eq) {
19 std::cout << "BINGO; Found the target, exiting\n";
20 std::cout.flush();
21 abort();
22 }
23 return 0;
24}
25