1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
5 #include "memory-util.h"
6 #include "memstream-util.h"
7 #include "resolved-dns-packet.h"
9 int LLVMFuzzerTestOneInput(const uint8_t *data
, size_t size
) {
10 _cleanup_(dns_resource_record_unrefp
) DnsResourceRecord
*rr
= NULL
, *copy
= NULL
;
11 _cleanup_(json_variant_unrefp
) JsonVariant
*v
= NULL
;
12 _cleanup_(memstream_done
) MemStream m
= {};
15 if (outside_size_range(size
, 0, DNS_PACKET_SIZE_MAX
))
18 if (dns_resource_record_new_from_raw(&rr
, data
, size
) < 0)
23 assert_se(copy
= dns_resource_record_copy(rr
));
24 assert_se(dns_resource_record_equal(copy
, rr
) > 0);
26 assert_se(f
= memstream_init(&m
));
27 (void) fprintf(f
, "%s", strna(dns_resource_record_to_string(rr
)));
29 if (dns_resource_record_to_json(rr
, &v
) < 0)
32 (void) json_variant_dump(v
, JSON_FORMAT_PRETTY
|JSON_FORMAT_COLOR
|JSON_FORMAT_SOURCE
, f
, NULL
);
33 (void) dns_resource_record_to_wire_format(rr
, false);
34 (void) dns_resource_record_to_wire_format(rr
, true);