blob: 4ed71d9d021dd561a52508bf5d70619cfc45b6af [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// Test that libFuzzer itself does not read out of bounds.
5#include <assert.h>
6#include <cstddef>
7#include <cstdint>
8#include <cstdlib>
9#include <cstring>
10#include <iostream>
11
12static volatile int Sink;
13
14extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
15 if (Size < 5) return 0;
16 const char *Ch = reinterpret_cast<const char *>(Data);
17 if (Ch[Size - 3] == 'a')
18 Sink = strncmp(Ch + Size - 3, "abcdefg", 6);
19 return 0;
20}
21