Electroneum
Toggle main menu visibility
Loading...
Searching...
No Matches
fuzzer.cpp
Go to the documentation of this file.
1
// Copyright (c) 2017-Present, Electroneum
2
// Copyright (c) 2017-2019, The Monero Project
3
//
4
// All rights reserved.
5
//
6
// Redistribution and use in source and binary forms, with or without modification, are
7
// permitted provided that the following conditions are met:
8
//
9
// 1. Redistributions of source code must retain the above copyright notice, this list of
10
// conditions and the following disclaimer.
11
//
12
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
13
// of conditions and the following disclaimer in the documentation and/or other
14
// materials provided with the distribution.
15
//
16
// 3. Neither the name of the copyright holder nor the names of its contributors may be
17
// used to endorse or promote products derived from this software without specific
18
// prior written permission.
19
//
20
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
21
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
22
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
23
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
28
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
30
#include <boost/program_options.hpp>
31
#include "
include_base_utils.h
"
32
#include "
string_tools.h
"
33
#include "
common/command_line.h
"
34
#include "
common/util.h
"
35
#include "
fuzzer.h
"
36
37
#if (!defined(__clang__) || (__clang__ < 5))
38
static
int
__AFL_LOOP(
int
)
39
{
40
static
int
once = 0;
41
if
(once)
42
return
0;
43
once = 1;
44
return
1;
45
}
46
#endif
47
48
int
run_fuzzer
(
int
argc,
const
char
**argv,
Fuzzer
&fuzzer)
49
{
50
TRY_ENTRY
();
51
52
if
(argc < 2)
53
{
54
std::cout <<
"usage: "
<< argv[0] <<
" "
<<
"<filename>"
<< std::endl;
55
return
1;
56
}
57
58
#ifdef __AFL_HAVE_MANUAL_CONTROL
59
__AFL_INIT();
60
#endif
61
62
int
ret = fuzzer.
init
();
63
if
(ret)
64
return
ret;
65
66
const
std::string filename = argv[1];
67
while
(__AFL_LOOP(1000))
68
{
69
ret = fuzzer.
run
(filename);
70
if
(ret)
71
return
ret;
72
}
73
74
return
0;
75
76
CATCH_ENTRY_L0
(
"run_fuzzer"
, 1);
77
}
Fuzzer
Definition
fuzzer.h:33
Fuzzer::init
virtual int init()
Definition
fuzzer.h:35
Fuzzer::run
virtual int run(const std::string &filename)=0
command_line.h
run_fuzzer
int run_fuzzer(int argc, const char **argv, Fuzzer &fuzzer)
Definition
fuzzer.cpp:48
fuzzer.h
include_base_utils.h
CATCH_ENTRY_L0
#define CATCH_ENTRY_L0(lacation, return_val)
Definition
misc_log_ex.h:165
TRY_ENTRY
#define TRY_ENTRY()
Definition
misc_log_ex.h:151
util.h
string_tools.h
tests
fuzz
fuzzer.cpp
Generated on
for Electroneum by
1.17.0