]>
git.proxmox.com Git - rustc.git/blob - src/libcompiler_builtins/compiler-rt/test/fuzzer/StrncmpTest.cpp
1 // This file is distributed under the University of Illinois Open Source
2 // License. See LICENSE.TXT for details.
4 // Simple test for a fuzzer. The fuzzer must find a particular string.
10 static volatile int sink
;
12 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data
, size_t Size
) {
13 // TODO: check other sizes.
14 const char *S
= (const char*)Data
;
15 if (Size
>= 8 && strncmp(S
, "123", 8))
17 if (Size
>= 8 && strncmp(S
, "01234567", 8) == 0) {
18 if (Size
>= 12 && strncmp(S
+ 8, "ABCD", 4) == 0) {
19 if (Size
>= 14 && strncmp(S
+ 12, "XY", 2) == 0) {
20 if (Size
>= 17 && strncmp(S
+ 14, "KLM", 3) == 0) {
21 fprintf(stderr
, "BINGO\n");