blob: bbfbefe6ab710836e5e8593641f973563f253223 [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// The fuzzer must find several constants with swapped bytes.
5#include <cstdint>
6#include <cstdio>
7#include <cstdlib>
8#include <cstring>
9
10extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
11 if (Size < 14) return 0;
12 uint64_t x = 0;
13 uint32_t y = 0;
14 uint16_t z = 0;
15 memcpy(&x, Data, sizeof(x));
16 memcpy(&y, Data + Size / 2, sizeof(y));
17 memcpy(&z, Data + Size - sizeof(z), sizeof(z));
18
19 x = __builtin_bswap64(x);
20 y = __builtin_bswap32(y);
21 z = __builtin_bswap16(z);
22 const bool k32bit = sizeof(void*) == 4;
23
24 if ((k32bit || x == 0x46555A5A5A5A5546ULL) &&
25 z == 0x4F4B &&
26 y == 0x66757A7A &&
27 true
28 ) {
29 if (Data[Size - 3] == 'z') {
30 fprintf(stderr, "BINGO; Found the target\n");
31 exit(1);
32 }
33 }
34 return 0;
35}