]> git.proxmox.com Git - ceph.git/blob - ceph/src/c-ares/test/ares-test-fuzz.c
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / c-ares / test / ares-test-fuzz.c
1 #include <stddef.h>
2
3 #include "ares.h"
4
5 // Entrypoint for Clang's libfuzzer
6 int LLVMFuzzerTestOneInput(const unsigned char *data,
7 unsigned long size) {
8 // Feed the data into each of the ares_parse_*_reply functions.
9 struct hostent *host = NULL;
10 struct ares_addrttl info[5];
11 int count = 5;
12 ares_parse_a_reply(data, size, &host, info, &count);
13 if (host) ares_free_hostent(host);
14
15 host = NULL;
16 struct ares_addr6ttl info6[5];
17 count = 5;
18 ares_parse_aaaa_reply(data, size, &host, info6, &count);
19 if (host) ares_free_hostent(host);
20
21 host = NULL;
22 unsigned char addrv4[4] = {0x10, 0x20, 0x30, 0x40};
23 ares_parse_ptr_reply(data, size, addrv4, sizeof(addrv4), AF_INET, &host);
24 if (host) ares_free_hostent(host);
25
26 host = NULL;
27 ares_parse_ns_reply(data, size, &host);
28 if (host) ares_free_hostent(host);
29
30 struct ares_srv_reply* srv = NULL;
31 ares_parse_srv_reply(data, size, &srv);
32 if (srv) ares_free_data(srv);
33
34 struct ares_mx_reply* mx = NULL;
35 ares_parse_mx_reply(data, size, &mx);
36 if (mx) ares_free_data(mx);
37
38 struct ares_txt_reply* txt = NULL;
39 ares_parse_txt_reply(data, size, &txt);
40 if (txt) ares_free_data(txt);
41
42 struct ares_soa_reply* soa = NULL;
43 ares_parse_soa_reply(data, size, &soa);
44 if (soa) ares_free_data(soa);
45 return 0;
46 }