]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Reject zero length ALPN elements in fromwire
authorMark Andrews <marka@isc.org>
Thu, 19 Aug 2021 01:09:45 +0000 (11:09 +1000)
committerMark Andrews <marka@isc.org>
Thu, 19 Aug 2021 08:17:08 +0000 (18:17 +1000)
lib/dns/rdata/in_1/svcb_64.c
lib/dns/tests/rdata_test.c

index 8fbb99c7b7bb9484b8c9cc7289c17242ed8417ee..e1cf27c1b76f38df8501c1c1df6a0b6dfd6dfa4f 100644 (file)
@@ -121,7 +121,7 @@ svcb_validate(uint16_t key, isc_region_t *region) {
                                }
                                while (region->length != 0) {
                                        size_t l = *region->base + 1;
-                                       if (l > region->length) {
+                                       if (l == 1U || l > region->length) {
                                                return (DNS_R_FORMERR);
                                        }
                                        isc_region_consume(region, l);
index 595fcf9dac6ee3bb6a93618048add8a9b494792e..d64ffce789fd33fe196316b7fe5e927f1d0c948b 100644 (file)
@@ -2723,6 +2723,11 @@ https_svcb(void **state) {
                 * no-default-alpn (0x00 0x02) without alpn, alpn is required.
                 */
                WIRE_INVALID(0x00, 0x00, 0x01, 0x00, 0x00, 0x02, 0x00, 0x00),
+               /*
+                * Alpn(0x00 0x01) with zero length elements is invalid
+                */
+               WIRE_INVALID(0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x05,
+                            0x00, 0x00, 0x00, 0x00, 0x00),
                WIRE_SENTINEL()
        };
        /* Test vectors from RFCXXXX */