comparison fuzzer-pubkey.c @ 1377:d4cc85e6c569 fuzz

rearrange, all fuzzers now call fuzzer_set_input()
author Matt Johnston <matt@ucc.asn.au>
date Thu, 25 May 2017 22:21:49 +0800
parents ddfcadca3c4c
children 7209a6e30932
comparison
equal deleted inserted replaced
1376:9e9c8d37fd56 1377:d4cc85e6c569
12 if (!once) { 12 if (!once) {
13 setup_fuzzer(); 13 setup_fuzzer();
14 once = 1; 14 once = 1;
15 } 15 }
16 16
17 if (fuzzer_set_input(Data, Size) == DROPBEAR_FAILURE) {
18 return 0;
19 }
20
17 m_malloc_set_epoch(1); 21 m_malloc_set_epoch(1);
18 22
19 fuzz_seed(); 23 // choose a keytype based on input
20 fuzz.input->data = (unsigned char*)Data; 24 uint8_t b = 0;
21 fuzz.input->len = Size; 25 size_t i;
22 fuzz.input->size = Size; 26 for (i = 0; i < Size; i++) {
23 fuzz.input->pos = 0; 27 b ^= Data[i];
24 28 }
25 if (Size < 4) { 29 const char* algoname = fuzz_signkey_names[b%DROPBEAR_SIGNKEY_NUM_NAMED];
26 return 0; 30 const char* keyblob = "blob"; // keep short
27 }
28
29 // choose a keytype based on input
30 uint8_t b = 0;
31 size_t i;
32 for (i = 0; i < Size; i++) {
33 b ^= Data[i];
34 }
35 const char* algoname = fuzz_signkey_names[b%DROPBEAR_SIGNKEY_NUM_NAMED];
36 const char* keyblob = "fakekeyblob";
37 31
38 if (setjmp(fuzz.jmp) == 0) { 32 if (setjmp(fuzz.jmp) == 0) {
39 fuzz_checkpubkey_line(fuzz.input, 5, "/home/me/authorized_keys", 33 fuzz_checkpubkey_line(fuzz.input, 5, "/home/me/authorized_keys",
40 algoname, strlen(algoname), 34 algoname, strlen(algoname),
41 keyblob, strlen(keyblob)); 35 keyblob, strlen(keyblob));