]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Check that a short PRIVATEDNS record is rejected
authorMark Andrews <marka@isc.org>
Tue, 19 May 2026 02:03:23 +0000 (12:03 +1000)
committerMichał Kępień <michal@isc.org>
Fri, 10 Jul 2026 07:26:46 +0000 (09:26 +0200)
A bug in dns_name_fromwire meant that short PRIVATEDNS key
records where being accepted.  Test that this is no longer
the case.

tests/dns/rdata_test.c

index aafa7e04523a7e9d01f155fdf71a9dcbe75c7bb2..84361b7606663465f90c40b7b84246236e383732 100644 (file)
@@ -2322,6 +2322,25 @@ ISC_RUN_TEST_IMPL(key) {
 
        check_rdata(text_ok, wire_ok, NULL, false, dns_rdataclass_in,
                    dns_rdatatype_key, sizeof(dns_rdata_key_t));
+
+       /*
+        * A valid PRIVATEDNS record with an active region shorter than the
+        * actual record length.  A bug in dns_name_fromwire meant that this
+        * was previously accepted.
+        */
+       unsigned char key[] = { 0x00, 0x00, 0x00, 253, 0x07, 'e', 'x',
+                               'a',  'm',  'p',  'l', 'e',  0x00 };
+       unsigned char buf[sizeof(key)];
+       isc_buffer_t source, target;
+       isc_result_t result;
+
+       isc_buffer_init(&source, key, sizeof(key));
+       isc_buffer_add(&source, sizeof(key));
+       isc_buffer_setactive(&source, sizeof(key) - 1);
+       isc_buffer_init(&target, buf, sizeof(buf));
+       result = dns_rdata_fromwire(NULL, dns_rdataclass_in, dns_rdatatype_key,
+                                   &source, DNS_DECOMPRESS_ALWAYS, &target);
+       assert_int_not_equal(result, ISC_R_SUCCESS);
 }
 
 /*