annotate fuzz-harness.c @ 1597:8f7b6f75aa58

fix uninitialised memory in fuzzer codepath
author Matt Johnston <matt@ucc.asn.au>
date Tue, 06 Mar 2018 22:02:19 +0800
parents 35af85194268
children bff41a61a1b6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1348
5c2899e35b63 fuzz harness
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1 #include "includes.h"
1354
7618759e9327 better harness
Matt Johnston <matt@ucc.asn.au>
parents: 1348
diff changeset
2 #include "buffer.h"
7618759e9327 better harness
Matt Johnston <matt@ucc.asn.au>
parents: 1348
diff changeset
3 #include "dbutil.h"
1348
5c2899e35b63 fuzz harness
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4
5c2899e35b63 fuzz harness
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5 extern int LLVMFuzzerTestOneInput(const unsigned char *data, size_t size);
5c2899e35b63 fuzz harness
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6
5c2899e35b63 fuzz harness
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7 int main(int argc, char ** argv) {
1354
7618759e9327 better harness
Matt Johnston <matt@ucc.asn.au>
parents: 1348
diff changeset
8 int i;
7618759e9327 better harness
Matt Johnston <matt@ucc.asn.au>
parents: 1348
diff changeset
9 buffer *input = buf_new(100000);
7618759e9327 better harness
Matt Johnston <matt@ucc.asn.au>
parents: 1348
diff changeset
10
1363
b2f295125ed6 -v for debug_trace
Matt Johnston <matt@ucc.asn.au>
parents: 1358
diff changeset
11 for (i = 1; i < argc; i++) {
1589
35af85194268 Add kexdh and kexecdh fuzzers
Matt Johnston <matt@ucc.asn.au>
parents: 1559
diff changeset
12 printf("arg %s\n", argv[i]);
1363
b2f295125ed6 -v for debug_trace
Matt Johnston <matt@ucc.asn.au>
parents: 1358
diff changeset
13 #if DEBUG_TRACE
b2f295125ed6 -v for debug_trace
Matt Johnston <matt@ucc.asn.au>
parents: 1358
diff changeset
14 if (strcmp(argv[i], "-v") == 0) {
b2f295125ed6 -v for debug_trace
Matt Johnston <matt@ucc.asn.au>
parents: 1358
diff changeset
15 debug_trace = 1;
1373
9891bc31a1b3 fuzzers disable logging by default
Matt Johnston <matt@ucc.asn.au>
parents: 1363
diff changeset
16 TRACE(("debug printing on"))
1363
b2f295125ed6 -v for debug_trace
Matt Johnston <matt@ucc.asn.au>
parents: 1358
diff changeset
17 }
1357
08f4fa4dc6a0 closer to working
Matt Johnston <matt@ucc.asn.au>
parents: 1354
diff changeset
18 #endif
1363
b2f295125ed6 -v for debug_trace
Matt Johnston <matt@ucc.asn.au>
parents: 1358
diff changeset
19 }
1357
08f4fa4dc6a0 closer to working
Matt Johnston <matt@ucc.asn.au>
parents: 1354
diff changeset
20
1354
7618759e9327 better harness
Matt Johnston <matt@ucc.asn.au>
parents: 1348
diff changeset
21 for (i = 1; i < argc; i++) {
1363
b2f295125ed6 -v for debug_trace
Matt Johnston <matt@ucc.asn.au>
parents: 1358
diff changeset
22 if (argv[i][0] == '-') {
1559
92c93b4a3646 Fix to be able to compile normal(ish) binaries with --enable-fuzz
Matt Johnston <matt@ucc.asn.au>
parents: 1373
diff changeset
23 /* ignore arguments */
1363
b2f295125ed6 -v for debug_trace
Matt Johnston <matt@ucc.asn.au>
parents: 1358
diff changeset
24 continue;
b2f295125ed6 -v for debug_trace
Matt Johnston <matt@ucc.asn.au>
parents: 1358
diff changeset
25 }
b2f295125ed6 -v for debug_trace
Matt Johnston <matt@ucc.asn.au>
parents: 1358
diff changeset
26
1354
7618759e9327 better harness
Matt Johnston <matt@ucc.asn.au>
parents: 1348
diff changeset
27 char* fn = argv[i];
7618759e9327 better harness
Matt Johnston <matt@ucc.asn.au>
parents: 1348
diff changeset
28 buf_setlen(input, 0);
7618759e9327 better harness
Matt Johnston <matt@ucc.asn.au>
parents: 1348
diff changeset
29 buf_readfile(input, fn);
7618759e9327 better harness
Matt Johnston <matt@ucc.asn.au>
parents: 1348
diff changeset
30 buf_setpos(input, 0);
7618759e9327 better harness
Matt Johnston <matt@ucc.asn.au>
parents: 1348
diff changeset
31
1358
6b89eb92f872 glaring wrapfd problems fixed
Matt Johnston <matt@ucc.asn.au>
parents: 1357
diff changeset
32 printf("Running %s once \n", fn);
6b89eb92f872 glaring wrapfd problems fixed
Matt Johnston <matt@ucc.asn.au>
parents: 1357
diff changeset
33 LLVMFuzzerTestOneInput(input->data, input->len);
6b89eb92f872 glaring wrapfd problems fixed
Matt Johnston <matt@ucc.asn.au>
parents: 1357
diff changeset
34 printf("Running %s twice \n", fn);
1354
7618759e9327 better harness
Matt Johnston <matt@ucc.asn.au>
parents: 1348
diff changeset
35 LLVMFuzzerTestOneInput(input->data, input->len);
7618759e9327 better harness
Matt Johnston <matt@ucc.asn.au>
parents: 1348
diff changeset
36 printf("Done %s\n", fn);
7618759e9327 better harness
Matt Johnston <matt@ucc.asn.au>
parents: 1348
diff changeset
37 }
7618759e9327 better harness
Matt Johnston <matt@ucc.asn.au>
parents: 1348
diff changeset
38
7618759e9327 better harness
Matt Johnston <matt@ucc.asn.au>
parents: 1348
diff changeset
39 printf("Finished\n");
7618759e9327 better harness
Matt Johnston <matt@ucc.asn.au>
parents: 1348
diff changeset
40
1348
5c2899e35b63 fuzz harness
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
41 return 0;
5c2899e35b63 fuzz harness
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
42 }