]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
fuzz: check that resource records are serialized successfully
authorEvgeny Vereshchagin <evvers@ya.ru>
Fri, 12 Apr 2024 08:59:26 +0000 (08:59 +0000)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 12 Apr 2024 20:18:12 +0000 (05:18 +0900)
It shouldn't fail at that point.

It's prompted by the "Structure needs cleaning" thing that keeps popping
up in various places like
https://github.com/systemd/systemd/pull/30952#discussion_r1553181309 and
https://github.com/systemd/systemd/issues/31708.

src/resolve/fuzz-resource-record.c

index 358a5c7594b887b9805724957541bc8996059987..f792167aff3fd133912352fc5447a218fc87ab50 100644 (file)
@@ -26,12 +26,10 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
         assert_se(f = memstream_init(&m));
         (void) fprintf(f, "%s", strna(dns_resource_record_to_string(rr)));
 
-        if (dns_resource_record_to_json(rr, &v) < 0)
-                return 0;
-
-        (void) json_variant_dump(v, JSON_FORMAT_PRETTY|JSON_FORMAT_COLOR|JSON_FORMAT_SOURCE, f, NULL);
-        (void) dns_resource_record_to_wire_format(rr, false);
-        (void) dns_resource_record_to_wire_format(rr, true);
+        assert_se(dns_resource_record_to_json(rr, &v) >= 0);
+        assert_se(json_variant_dump(v, JSON_FORMAT_PRETTY|JSON_FORMAT_COLOR|JSON_FORMAT_SOURCE, f, NULL) >= 0);
+        assert_se(dns_resource_record_to_wire_format(rr, false) >= 0);
+        assert_se(dns_resource_record_to_wire_format(rr, true) >= 0);
 
         return 0;
 }