1 #include "config.h"
2 #include "sldns/sbuffer.h"
3 #include "sldns/wire2str.h"
4 #include "sldns/str2wire.h"
5 #include "util/data/dname.h"
6
7 #define SZ 1000
8 #define SZ2 100
9
10
LLVMFuzzerTestOneInput(const uint8_t * buf,size_t nr)11 int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t nr) {
12 char *bin = malloc(nr);
13 uint8_t *bout;
14 size_t len, len2;
15
16 memset(bin, 0, nr);
17 memcpy(bin, buf, nr);
18
19 if (nr > 2) {
20 bin[nr-1] = 0x00; // null terminate
21 len = bin[0] & 0xff; // want random sized output buf
22 bout = malloc(len);
23 nr--;
24 bin++;
25
26 // call the targets
27 len2 = len; sldns_str2wire_dname_buf(bin, bout, &len2);
28 len2 = len; sldns_str2wire_int8_buf(bin, bout, &len2);
29 len2 = len; sldns_str2wire_int16_buf(bin, bout, &len2);
30 len2 = len; sldns_str2wire_int32_buf(bin, bout, &len2);
31 len2 = len; sldns_str2wire_a_buf(bin, bout, &len2);
32 len2 = len; sldns_str2wire_aaaa_buf(bin, bout, &len2);
33 len2 = len; sldns_str2wire_str_buf(bin, bout, &len2);
34 len2 = len; sldns_str2wire_apl_buf(bin, bout, &len2);
35 len2 = len; sldns_str2wire_b64_buf(bin, bout, &len2);
36 len2 = len; sldns_str2wire_b32_ext_buf(bin, bout, &len2);
37 len2 = len; sldns_str2wire_hex_buf(bin, bout, &len2);
38 len2 = len; sldns_str2wire_nsec_buf(bin, bout, &len2);
39 len2 = len; sldns_str2wire_type_buf(bin, bout, &len2);
40 len2 = len; sldns_str2wire_class_buf(bin, bout, &len2);
41 len2 = len; sldns_str2wire_cert_alg_buf(bin, bout, &len2);
42 len2 = len; sldns_str2wire_alg_buf(bin, bout, &len2);
43 len2 = len; sldns_str2wire_tsigerror_buf(bin, bout, &len2);
44 len2 = len; sldns_str2wire_time_buf(bin, bout, &len2);
45 len2 = len; sldns_str2wire_tsigtime_buf(bin, bout, &len2);
46 len2 = len; sldns_str2wire_period_buf(bin, bout, &len2);
47 len2 = len; sldns_str2wire_loc_buf(bin, bout, &len2);
48 len2 = len; sldns_str2wire_wks_buf(bin, bout, &len2);
49 len2 = len; sldns_str2wire_nsap_buf(bin, bout, &len2);
50 len2 = len; sldns_str2wire_atma_buf(bin, bout, &len2);
51 len2 = len; sldns_str2wire_ipseckey_buf(bin, bout, &len2);
52 len2 = len; sldns_str2wire_nsec3_salt_buf(bin, bout, &len2);
53 len2 = len; sldns_str2wire_ilnp64_buf(bin, bout, &len2);
54 len2 = len; sldns_str2wire_eui48_buf(bin, bout, &len2);
55 len2 = len; sldns_str2wire_eui64_buf(bin, bout, &len2);
56 len2 = len; sldns_str2wire_tag_buf(bin, bout, &len2);
57 len2 = len; sldns_str2wire_long_str_buf(bin, bout, &len2);
58 len2 = len; sldns_str2wire_hip_buf(bin, bout, &len2);
59 len2 = len; sldns_str2wire_int16_data_buf(bin, bout, &len2);
60
61 bin--;
62 free(bout);
63 }
64
65 out:
66 free(bin);
67 }
68