LLVM
4.0.0
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
llvm.src
lib
Fuzzer
test
CallerCalleeTest.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.
5
// Try to find the target using the indirect caller-callee pairs.
6
#include <cstdint>
7
#include <cstdlib>
8
#include <cstddef>
9
#include <cstring>
10
#include <iostream>
11
12
typedef
void (*
F
)();
13
static
F
t
[256];
14
15
void
f34
() {
16
std::cerr <<
"BINGO\n"
;
17
exit(1);
18
}
19
void
f23
() {
t
[(
unsigned
)
'd'
] =
f34
;}
20
void
f12
() {
t
[(
unsigned
)
'c'
] =
f23
;}
21
void
f01
() {
t
[(
unsigned
)
'b'
] =
f12
;}
22
void
f00
() {}
23
24
static
F
t0
[256] = {
25
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
26
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
27
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
28
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
29
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
30
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
31
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
32
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
33
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
34
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
35
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
36
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
37
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
38
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
39
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
40
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
f00
,
41
};
42
43
extern
"C"
int
LLVMFuzzerTestOneInput
(
const
uint8_t *Data,
size_t
Size) {
44
if
(Size < 4)
return
0;
45
// Spoof the counters.
46
for
(
int
i
= 0;
i
< 200;
i
++) {
47
f23
();
48
f12
();
49
f01
();
50
}
51
memcpy(
t
,
t0
,
sizeof
(
t
));
52
t
[(
unsigned
)
'a'
] =
f01
;
53
t
[Data[0]]();
54
t
[Data[1]]();
55
t
[Data[2]]();
56
t
[Data[3]]();
57
return
0;
58
}
59
f12
void f12()
Definition:
CallerCalleeTest.cpp:20
i
size_t i
Definition:
FuzzerTracePC.cpp:312
t0
static F t0[256]
Definition:
CallerCalleeTest.cpp:24
f00
void f00()
Definition:
CallerCalleeTest.cpp:22
f23
void f23()
Definition:
CallerCalleeTest.cpp:19
t
static F t[256]
Definition:
CallerCalleeTest.cpp:13
f34
void f34()
Definition:
CallerCalleeTest.cpp:15
unsigned
LLVMFuzzerTestOneInput
int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
Definition:
CallerCalleeTest.cpp:43
f01
void f01()
Definition:
CallerCalleeTest.cpp:21
F
void(* F)()
Definition:
CallerCalleeTest.cpp:12
Generated on Wed Mar 8 2017 17:06:54 for LLVM by
1.8.6