File tree Expand file tree Collapse file tree 2 files changed +28
-3
lines changed Expand file tree Collapse file tree 2 files changed +28
-3
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,13 @@ We disable ccache because we don't want to pollute the ccache with instrumented
32
32
objects, and similarly don't want to use non-instrumented cached objects linked
33
33
in.
34
34
35
+ The fuzzing can be sped up significantly (~ 200x) by using ` afl-clang-fast ` and
36
+ ` afl-clang-fast++ ` in place of ` afl-gcc ` and ` afl-g++ ` when compiling. When
37
+ compiling using ` afl-clang-fast ` /` afl-clang-fast++ ` the resulting
38
+ ` test_bitcoin_fuzzy ` binary will be instrumented in such a way that the AFL
39
+ features "persistent mode" and "deferred forkserver" can be used. See
40
+ https://github.com/mcarpenter/afl/tree/master/llvm_mode for details.
41
+
35
42
Preparing fuzzing
36
43
------------------
37
44
@@ -63,4 +70,3 @@ $AFLPATH/afl-fuzz -i ${AFLIN} -o ${AFLOUT} -m52 -- test/test_bitcoin_fuzzy
63
70
64
71
You may have to change a few kernel parameters to test optimally - ` afl-fuzz `
65
72
will print an error and suggestion if so.
66
-
Original file line number Diff line number Diff line change @@ -59,9 +59,8 @@ bool read_stdin(std::vector<char> &data) {
59
59
return length==0 ;
60
60
}
61
61
62
- int main ( int argc, char **argv )
62
+ int do_fuzz ( )
63
63
{
64
- ECCVerifyHandle globalVerifyHandle;
65
64
std::vector<char > buffer;
66
65
if (!read_stdin (buffer)) return 0 ;
67
66
@@ -256,3 +255,23 @@ int main(int argc, char **argv)
256
255
return 0 ;
257
256
}
258
257
258
+ int main (int argc, char **argv)
259
+ {
260
+ ECCVerifyHandle globalVerifyHandle;
261
+ #ifdef __AFL_INIT
262
+ // Enable AFL deferred forkserver mode. Requires compilation using
263
+ // afl-clang-fast++. See fuzzing.md for details.
264
+ __AFL_INIT ();
265
+ #endif
266
+
267
+ #ifdef __AFL_LOOP
268
+ // Enable AFL persistent mode. Requires compilation using afl-clang-fast++.
269
+ // See fuzzing.md for details.
270
+ while (__AFL_LOOP (1000 )) {
271
+ do_fuzz ();
272
+ }
273
+ return 0 ;
274
+ #else
275
+ return do_fuzz ();
276
+ #endif
277
+ }
You can’t perform that action at this time.
0 commit comments