LLVM
5.0.0
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
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 <cstddef>
7
#include <cstdint>
8
#include <cstdlib>
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
llvm::Data
Definition:
SIMachineScheduler.h:59
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
llvm::AMDGPU::CodeObject::Kernel::Arg::Key::Size
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
Definition:
AMDGPUCodeObjectMetadata.h:154
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Generated on Fri Sep 1 2017 14:13:37 for LLVM by
1.8.6