From: Bob Halley Date: Tue, 6 Oct 2020 16:26:57 +0000 (-0700) Subject: The alias target of an SVCB or HTTPS rdata must not be compressed. X-Git-Tag: v2.1.0rc1~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=21ec1198f9a3941c0b4f6aee1acca8897bbbb489;p=thirdparty%2Fdnspython.git The alias target of an SVCB or HTTPS rdata must not be compressed. --- diff --git a/dns/rdtypes/svcbbase.py b/dns/rdtypes/svcbbase.py index 585c05e0..b8b40594 100644 --- a/dns/rdtypes/svcbbase.py +++ b/dns/rdtypes/svcbbase.py @@ -497,7 +497,7 @@ class SVCBBase(dns.rdata.Rdata): def _to_wire(self, file, compress=None, origin=None, canonicalize=False): file.write(struct.pack("!H", self.priority)) - self.target.to_wire(file, compress, origin, canonicalize) + self.target.to_wire(file, None, origin, canonicalize) for key in sorted(self.params): file.write(struct.pack("!H", key)) value = self.params[key] diff --git a/tests/test_svcb.py b/tests/test_svcb.py index ff8dead6..51126df9 100644 --- a/tests/test_svcb.py +++ b/tests/test_svcb.py @@ -1,9 +1,11 @@ # Copyright (C) Dnspython Contributors, see LICENSE for text of ISC license +import io import unittest import dns.rdata import dns.rdtypes.svcbbase +import dns.rrset class SVCBTestCase(unittest.TestCase): def check_valid_inputs(self, inputs): @@ -310,3 +312,15 @@ class SVCBTestCase(unittest.TestCase): alpn.ids = 'foo' with self.assertRaises(TypeError): del alpn.ids + + def test_alias_not_compressed(self): + rrs = dns.rrset.from_text('elsewhere.', 300, 'in', 'svcb', + '0 elsewhere.') + output = io.BytesIO() + compress = {} + rrs.to_wire(output, compress) + wire = output.getvalue() + # Just one of these assertions is enough, but we do both to show + # the bug we're checking is fixed. + assert not wire.endswith(b'\xc0\x00') + assert wire.endswith(b'\x09elsewhere\x00')