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// Simple test for a fuzzer: find interesting value of array index.
5c5f01b2fSopenharmony_ci#include <assert.h>
6c5f01b2fSopenharmony_ci#include <cstdint>
7c5f01b2fSopenharmony_ci#include <cstring>
8c5f01b2fSopenharmony_ci#include <cstddef>
9c5f01b2fSopenharmony_ci#include <iostream>
10c5f01b2fSopenharmony_ci
11c5f01b2fSopenharmony_cistatic volatile int Sink;
12c5f01b2fSopenharmony_ciconst int kArraySize = 1234567;
13c5f01b2fSopenharmony_ciint array[kArraySize];
14c5f01b2fSopenharmony_ci
15c5f01b2fSopenharmony_ciextern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
16c5f01b2fSopenharmony_ci  if (Size < 8) return 0;
17c5f01b2fSopenharmony_ci  size_t a = 0;
18c5f01b2fSopenharmony_ci  memcpy(&a, Data, 8);
19c5f01b2fSopenharmony_ci  Sink = array[a % (kArraySize + 1)];
20c5f01b2fSopenharmony_ci  return 0;
21c5f01b2fSopenharmony_ci}
22c5f01b2fSopenharmony_ci
23