Mercurial > dropbear
annotate fuzzer-verify.c @ 1457:32f990cc96b1 fuzz
fix bad assertion
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Tue, 23 Jan 2018 23:27:40 +0800 |
parents | a90fdd2d2ed8 |
children | 66a1a2547133 |
rev | line source |
---|---|
1380 | 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:
1380
diff
changeset
|
7 fuzz_common_setup(); |
1380 | 8 } |
9 | |
10 static buffer *verifydata; | |
11 | |
12 /* Tests reading a public key and verifying a signature */ | |
13 int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { | |
14 static int once = 0; | |
15 if (!once) { | |
16 setup_fuzzer(); | |
17 verifydata = buf_new(30); | |
18 buf_putstring(verifydata, "x", 1); | |
19 once = 1; | |
20 } | |
21 | |
1456
a90fdd2d2ed8
add fuzzer-preauth_nomaths
Matt Johnston <matt@ucc.asn.au>
parents:
1380
diff
changeset
|
22 if (fuzz_set_input(Data, Size) == DROPBEAR_FAILURE) { |
1380 | 23 return 0; |
24 } | |
25 | |
26 m_malloc_set_epoch(1); | |
27 | |
28 if (setjmp(fuzz.jmp) == 0) { | |
29 sign_key *key = new_sign_key(); | |
30 enum signkey_type type = DROPBEAR_SIGNKEY_ANY; | |
31 if (buf_get_pub_key(fuzz.input, key, &type) == DROPBEAR_SUCCESS) { | |
32 /* Don't expect random fuzz input to verify */ | |
33 assert(buf_verify(fuzz.input, key, verifydata) == DROPBEAR_FAILURE); | |
34 } | |
35 sign_key_free(key); | |
36 m_malloc_free_epoch(1, 0); | |
37 } else { | |
38 m_malloc_free_epoch(1, 1); | |
39 TRACE(("dropbear_exit longjmped")) | |
40 // dropbear_exit jumped here | |
41 } | |
42 | |
43 return 0; | |
44 } |