Mercurial > dropbear
comparison fuzz/fuzz-harness.c @ 1756:d5680e12ac33
Move fuzzing code to fuzz/ subdirectory, improve Makefile.in
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Fri, 23 Oct 2020 23:10:20 +0800 |
parents | fuzz-harness.c@d1b279aa5ed1 |
children | 2406a9987810 |
comparison
equal
deleted
inserted
replaced
1753:7c0fcd19e492 | 1756:d5680e12ac33 |
---|---|
1 #include "includes.h" | |
2 #include "buffer.h" | |
3 #include "dbutil.h" | |
4 | |
5 extern int LLVMFuzzerTestOneInput(const unsigned char *data, size_t size); | |
6 | |
7 int main(int argc, char ** argv) { | |
8 int i; | |
9 buffer *input = buf_new(100000); | |
10 | |
11 for (i = 1; i < argc; i++) { | |
12 #if DEBUG_TRACE | |
13 if (strcmp(argv[i], "-v") == 0) { | |
14 debug_trace = 1; | |
15 TRACE(("debug printing on")) | |
16 } | |
17 #endif | |
18 } | |
19 | |
20 int old_fuzz_wrapfds = 0; | |
21 for (i = 1; i < argc; i++) { | |
22 if (argv[i][0] == '-') { | |
23 /* ignore arguments */ | |
24 continue; | |
25 } | |
26 | |
27 char* fn = argv[i]; | |
28 buf_setlen(input, 0); | |
29 buf_readfile(input, fn); | |
30 buf_setpos(input, 0); | |
31 | |
32 /* Run twice to catch problems with statefulness */ | |
33 fuzz.wrapfds = old_fuzz_wrapfds; | |
34 printf("Running %s once \n", fn); | |
35 LLVMFuzzerTestOneInput(input->data, input->len); | |
36 printf("Running %s twice \n", fn); | |
37 LLVMFuzzerTestOneInput(input->data, input->len); | |
38 printf("Done %s\n", fn); | |
39 | |
40 /* Disable wrapfd so it won't interfere with buf_readfile() above */ | |
41 old_fuzz_wrapfds = fuzz.wrapfds; | |
42 fuzz.wrapfds = 0; | |
43 } | |
44 | |
45 printf("Finished\n"); | |
46 | |
47 return 0; | |
48 } |