1c5f01b2fSopenharmony_ci// This file is distributed under the University of Illinois Open Source
2c5f01b2fSopenharmony_ci// License. See LICENSE.TXT for details.
3c5f01b2fSopenharmony_ci
4c5f01b2fSopenharmony_ci// Test that libFuzzer itself does not read out of bounds.
5c5f01b2fSopenharmony_ci#include <assert.h>
6c5f01b2fSopenharmony_ci#include <cstdint>
7c5f01b2fSopenharmony_ci#include <cstring>
8c5f01b2fSopenharmony_ci#include <cstdlib>
9c5f01b2fSopenharmony_ci#include <cstddef>
10c5f01b2fSopenharmony_ci#include <iostream>
11c5f01b2fSopenharmony_ci
12c5f01b2fSopenharmony_cistatic volatile int Sink;
13c5f01b2fSopenharmony_ci
14c5f01b2fSopenharmony_ciextern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
15c5f01b2fSopenharmony_ci  if (Size < 5) return 0;
16c5f01b2fSopenharmony_ci  const char *Ch = reinterpret_cast<const char *>(Data);
17c5f01b2fSopenharmony_ci  if (Ch[Size - 3] == 'a')
18c5f01b2fSopenharmony_ci    Sink = strncmp(Ch + Size - 3, "abcdefg", 6);
19c5f01b2fSopenharmony_ci  return 0;
20c5f01b2fSopenharmony_ci}
21c5f01b2fSopenharmony_ci
22