Mercurial > dropbear
annotate fuzzer-pubkey.c @ 1595:4fe7cc9e45eb
reduce number of dh parameters so fuzzer doesn't timeout
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Tue, 06 Mar 2018 21:00:09 +0800 |
parents | e6a5e51a29c9 |
children | 252b406d0e9a |
rev | line source |
---|---|
1369 | 1 #include "fuzz.h" |
2 #include "session.h" | |
3 #include "fuzz-wrapfd.h" | |
4 #include "debug.h" | |
5 | |
6 static void setup_fuzzer(void) { | |
1456
a90fdd2d2ed8
add fuzzer-preauth_nomaths
Matt Johnston <matt@ucc.asn.au>
parents:
1383
diff
changeset
|
7 fuzz_common_setup(); |
1369 | 8 } |
9 | |
10 int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { | |
11 static int once = 0; | |
12 if (!once) { | |
13 setup_fuzzer(); | |
14 once = 1; | |
15 } | |
16 | |
1456
a90fdd2d2ed8
add fuzzer-preauth_nomaths
Matt Johnston <matt@ucc.asn.au>
parents:
1383
diff
changeset
|
17 if (fuzz_set_input(Data, Size) == DROPBEAR_FAILURE) { |
1377
d4cc85e6c569
rearrange, all fuzzers now call fuzzer_set_input()
Matt Johnston <matt@ucc.asn.au>
parents:
1369
diff
changeset
|
18 return 0; |
d4cc85e6c569
rearrange, all fuzzers now call fuzzer_set_input()
Matt Johnston <matt@ucc.asn.au>
parents:
1369
diff
changeset
|
19 } |
d4cc85e6c569
rearrange, all fuzzers now call fuzzer_set_input()
Matt Johnston <matt@ucc.asn.au>
parents:
1369
diff
changeset
|
20 |
1369 | 21 m_malloc_set_epoch(1); |
22 | |
1584
cdfab509c392
use random keyblob from the fuzzer instead
Matt Johnston <matt@ucc.asn.au>
parents:
1559
diff
changeset
|
23 if (setjmp(fuzz.jmp) == 0) { |
cdfab509c392
use random keyblob from the fuzzer instead
Matt Johnston <matt@ucc.asn.au>
parents:
1559
diff
changeset
|
24 buffer *line = buf_getstringbuf(fuzz.input); |
cdfab509c392
use random keyblob from the fuzzer instead
Matt Johnston <matt@ucc.asn.au>
parents:
1559
diff
changeset
|
25 buffer *keyblob = buf_getstringbuf(fuzz.input); |
cdfab509c392
use random keyblob from the fuzzer instead
Matt Johnston <matt@ucc.asn.au>
parents:
1559
diff
changeset
|
26 |
cdfab509c392
use random keyblob from the fuzzer instead
Matt Johnston <matt@ucc.asn.au>
parents:
1559
diff
changeset
|
27 unsigned int algolen; |
1586
e6a5e51a29c9
- fuzzer-pubkey needs to free algoname, fix build
Matt Johnston <matt@ucc.asn.au>
parents:
1584
diff
changeset
|
28 char* algoname = buf_getstring(keyblob, &algolen); |
1369 | 29 |
1586
e6a5e51a29c9
- fuzzer-pubkey needs to free algoname, fix build
Matt Johnston <matt@ucc.asn.au>
parents:
1584
diff
changeset
|
30 if (have_algo(algoname, algolen, sshhostkey) == DROPBEAR_FAILURE) { |
1584
cdfab509c392
use random keyblob from the fuzzer instead
Matt Johnston <matt@ucc.asn.au>
parents:
1559
diff
changeset
|
31 dropbear_exit("fuzzer imagined a bogus algorithm"); |
cdfab509c392
use random keyblob from the fuzzer instead
Matt Johnston <matt@ucc.asn.au>
parents:
1559
diff
changeset
|
32 } |
cdfab509c392
use random keyblob from the fuzzer instead
Matt Johnston <matt@ucc.asn.au>
parents:
1559
diff
changeset
|
33 fuzz_checkpubkey_line(line, 5, "/home/me/authorized_keys", |
cdfab509c392
use random keyblob from the fuzzer instead
Matt Johnston <matt@ucc.asn.au>
parents:
1559
diff
changeset
|
34 algoname, algolen, |
cdfab509c392
use random keyblob from the fuzzer instead
Matt Johnston <matt@ucc.asn.au>
parents:
1559
diff
changeset
|
35 keyblob->data, keyblob->len); |
cdfab509c392
use random keyblob from the fuzzer instead
Matt Johnston <matt@ucc.asn.au>
parents:
1559
diff
changeset
|
36 |
cdfab509c392
use random keyblob from the fuzzer instead
Matt Johnston <matt@ucc.asn.au>
parents:
1559
diff
changeset
|
37 buf_free(line); |
cdfab509c392
use random keyblob from the fuzzer instead
Matt Johnston <matt@ucc.asn.au>
parents:
1559
diff
changeset
|
38 buf_free(keyblob); |
1586
e6a5e51a29c9
- fuzzer-pubkey needs to free algoname, fix build
Matt Johnston <matt@ucc.asn.au>
parents:
1584
diff
changeset
|
39 m_free(algoname); |
1383
f03cfe9c76ac
Disable setnonblocking(), get_socket_address(), set_sock_priority()
Matt Johnston <matt@ucc.asn.au>
parents:
1378
diff
changeset
|
40 m_malloc_free_epoch(1, 0); |
1369 | 41 } else { |
1378 | 42 m_malloc_free_epoch(1, 1); |
1369 | 43 TRACE(("dropbear_exit longjmped")) |
1559
92c93b4a3646
Fix to be able to compile normal(ish) binaries with --enable-fuzz
Matt Johnston <matt@ucc.asn.au>
parents:
1456
diff
changeset
|
44 /* dropbear_exit jumped here */ |
1369 | 45 } |
46 | |
47 return 0; | |
48 } |