annotate compiler-rt/test/fuzzer/SingleMemcmpTest.cpp @ 207:2e18cbf3894f

LLVM12
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 08 Jun 2021 06:07:14 +0900
parents 1d019706d866
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
anatofuz
parents:
diff changeset
2 // See https://llvm.org/LICENSE.txt for license information.
anatofuz
parents:
diff changeset
3 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
anatofuz
parents:
diff changeset
4
anatofuz
parents:
diff changeset
5 // Simple test for a fuzzer. The fuzzer must find a particular string.
anatofuz
parents:
diff changeset
6 #include <cstdint>
anatofuz
parents:
diff changeset
7 #include <cstdio>
anatofuz
parents:
diff changeset
8 #include <cstdlib>
anatofuz
parents:
diff changeset
9 #include <cstring>
anatofuz
parents:
diff changeset
10
anatofuz
parents:
diff changeset
11 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
anatofuz
parents:
diff changeset
12 const char *S = (const char*)Data;
anatofuz
parents:
diff changeset
13 const char *Needle = "Some long string";
anatofuz
parents:
diff changeset
14 if (Size >= strlen(Needle) && !memcmp(S, Needle, strlen(Needle))) {
anatofuz
parents:
diff changeset
15 fprintf(stderr, "BINGO\n");
anatofuz
parents:
diff changeset
16 exit(1);
anatofuz
parents:
diff changeset
17 }
anatofuz
parents:
diff changeset
18 return 0;
anatofuz
parents:
diff changeset
19 }