comparison fuzzer-preauth.c @ 1356:3677a510f545 fuzz

add wrapfd. improve fuzzer in makefile
author Matt Johnston <matt@ucc.asn.au>
date Fri, 19 May 2017 00:48:46 +0800
parents 5c2899e35b63
children 08f4fa4dc6a0
comparison
equal deleted inserted replaced
1355:3fdd8c5a0195 1356:3677a510f545
1 #include "fuzz.h" 1 #include "fuzz.h"
2 #include "dbrandom.h" 2 #include "dbrandom.h"
3 #include "session.h" 3 #include "session.h"
4 #include "fuzz-wrapfd.h"
4 5
5 static int setup_fuzzer(void) { 6 static void setup_fuzzer(void) {
6 svr_setup_fuzzer(); 7 svr_setup_fuzzer();
7 return 0;
8 } 8 }
9 9
10 int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { 10 int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
11 static int once = 0; 11 static int once = 0;
12 if (!once) { 12 if (!once) {
13 setup_fuzzer(); 13 setup_fuzzer();
14 once = 1; 14 once = 1;
15 } 15 }
16 16
17 fuzz.input.data = (unsigned char*)Data; 17 if (fuzzer_set_input(Data, Size) == DROPBEAR_FAILURE) {
18 fuzz.input.size = Size; 18 return 0;
19 fuzz.input.len = Size; 19 }
20 fuzz.input.pos = 0;
21 20
22 seedrandom(); 21 int fakesock = 1;
22 wrapfd_add(fakesock, fuzz.input, PLAIN);
23 23
24 if (setjmp(fuzz.jmp) == 0) { 24 if (setjmp(fuzz.jmp) == 0) {
25 svr_session(-1, -1); 25 svr_session(fakesock, fakesock);
26 } else { 26 } else {
27 // dropbear_exit jumped here 27 // dropbear_exit jumped here
28 } 28 }
29 29
30 return 0; 30 return 0;