LLVM
4.0.0
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
llvm.src
lib
Fuzzer
test
RepeatedBytesTest.cpp
Go to the documentation of this file.
1
// This file is distributed under the University of Illinois Open Source
2
// License. See LICENSE.TXT for details.
3
4
// Simple test for a fuzzer. The fuzzer must find repeated bytes.
5
#include <assert.h>
6
#include <cstdint>
7
#include <cstdlib>
8
#include <cstddef>
9
#include <iostream>
10
11
extern
"C"
int
LLVMFuzzerTestOneInput
(
const
uint8_t *Data,
size_t
Size) {
12
assert
(Data);
13
// Looking for AAAAAAAAAAAAAAAAAAAAAA or some such.
14
size_t
CurA = 0, MaxA = 0;
15
for
(
size_t
i
= 0;
i
< Size;
i
++) {
16
// Make sure there are no conditionals in the loop so that
17
// coverage can't help the fuzzer.
18
int
EQ
= Data[
i
] ==
'A'
;
19
CurA = EQ * (CurA + 1);
20
int
GT
= CurA > MaxA;
21
MaxA = GT * CurA + (!
GT
) * MaxA;
22
}
23
if
(MaxA >= 20) {
24
std::cout <<
"BINGO; Found the target (Max: "
<< MaxA <<
"), exiting\n"
;
25
exit(0);
26
}
27
return
0;
28
}
29
i
size_t i
Definition:
FuzzerTracePC.cpp:312
LLVMFuzzerTestOneInput
int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
Definition:
RepeatedBytesTest.cpp:11
EQ
#define EQ(a, b)
Definition:
regexec.c:112
llvm::AArch64CC::GT
Definition:
AArch64BaseInfo.h:206
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Generated on Wed Mar 8 2017 17:21:55 for LLVM by
1.8.6