blob: 5a1329904612432a4e0150e12360d1ff86a7d467 [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 Serebryany1ce00352015-08-05 21:32:13 +00004// Break through a series of strcmp.
5#include <cstring>
6#include <cstdint>
7#include <cstdio>
8#include <cstdlib>
9#include <cassert>
10
11bool Eq(const uint8_t *Data, size_t Size, const char *Str) {
12 char Buff[1024];
13 size_t Len = strlen(Str);
14 if (Size < Len) return false;
15 if (Len >= sizeof(Buff)) return false;
16 memcpy(Buff, (char*)Data, Len);
17 Buff[Len] = 0;
18 int res = strcmp(Buff, Str);
19 return res == 0;
20}
21
Kostya Serebryany20bb5e72015-10-02 23:34:06 +000022extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
Kostya Serebryany1ce00352015-08-05 21:32:13 +000023 if (Eq(Data, Size, "AAA") &&
24 Size >= 3 && Eq(Data + 3, Size - 3, "BBBB") &&
25 Size >= 7 && Eq(Data + 7, Size - 7, "CCCCCC") &&
26 Size >= 14 && Data[13] == 42
27 ) {
28 fprintf(stderr, "BINGO\n");
29 exit(1);
30 }
Kostya Serebryany20bb5e72015-10-02 23:34:06 +000031 return 0;
Kostya Serebryany1ce00352015-08-05 21:32:13 +000032}