LLVM  4.0.0
LoadTest.cpp
Go to the documentation of this file.
1 // 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: find interesting value of array index.
5 #include <assert.h>
6 #include <cstdint>
7 #include <cstring>
8 #include <cstddef>
9 #include <iostream>
10 
11 static volatile int Sink;
12 const int kArraySize = 1234567;
14 
15 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
16  if (Size < 8) return 0;
17  size_t a = 0;
18  memcpy(&a, Data, 8);
19  Sink = array[a % (kArraySize + 1)];
20  return 0;
21 }
22 
static volatile int Sink
Definition: LoadTest.cpp:11
const int kArraySize
Definition: LoadTest.cpp:12
int array[kArraySize]
Definition: LoadTest.cpp:13
int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
Definition: LoadTest.cpp:15