blob: 54dc016ce8437e2fc461c9333a3bb5fd9affb88e [file] [log] [blame]
Mike Aizatskyf13cbee2016-04-01 18:38:58 +00001// This file is distributed under the University of Illinois Open Source
2// License. See LICENSE.TXT for details.
3
Kostya Serebryany16d03bd2015-03-30 22:09:51 +00004// Simple test for a fuzzer. The fuzzer must find several narrow ranges.
5#include <cstdint>
6#include <cstdlib>
7#include <cstring>
8#include <cstdio>
9
Kostya Serebryany20bb5e72015-10-02 23:34:06 +000010extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
11 if (Size < 14) return 0;
Kostya Serebryany16d03bd2015-03-30 22:09:51 +000012 uint64_t x = 0;
13 int64_t y = 0;
14 int z = 0;
15 unsigned short a = 0;
16 memcpy(&x, Data, 8);
17 memcpy(&y, Data + Size - 8, 8);
18 memcpy(&z, Data + Size / 2, sizeof(z));
19 memcpy(&a, Data + Size / 2 + 4, sizeof(a));
20
21 if (x > 1234567890 &&
22 x < 1234567895 &&
23 y >= 987654321 &&
24 y <= 987654325 &&
25 z < -10000 &&
26 z >= -10005 &&
27 z != -10003 &&
28 a == 4242) {
Kostya Serebryanya407dde2015-05-07 00:11:33 +000029 fprintf(stderr, "BINGO; Found the target: size %zd (%zd, %zd, %d, %d), exiting.\n",
Kostya Serebryany16d03bd2015-03-30 22:09:51 +000030 Size, x, y, z, a);
31 exit(1);
32 }
Kostya Serebryany20bb5e72015-10-02 23:34:06 +000033 return 0;
Kostya Serebryany16d03bd2015-03-30 22:09:51 +000034}