1 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
2 // See https://llvm.org/LICENSE.txt for license information.
3 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5 // Simple test for a fuzzer. The fuzzer must find repeated bytes.
13 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data
, size_t Size
) {
15 // Looking for AAAAAAAAAAAAAAAAAAAAAA or some such.
16 size_t CurA
= 0, MaxA
= 0;
17 for (size_t i
= 0; i
< Size
; i
++) {
18 // Make sure there are no conditionals in the loop so that
19 // coverage can't help the fuzzer.
20 int EQ
= Data
[i
] == 'A';
21 CurA
= EQ
* (CurA
+ 1);
23 MaxA
= GT
* CurA
+ (!GT
) * MaxA
;
26 std::cout
<< "BINGO; Found the target (Max: " << MaxA
<< "), exiting\n"