]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
The alias target of an SVCB or HTTPS rdata must not be compressed.
authorBob Halley <halley@dnspython.org>
Tue, 6 Oct 2020 16:26:57 +0000 (09:26 -0700)
committerBob Halley <halley@dnspython.org>
Tue, 6 Oct 2020 16:27:03 +0000 (09:27 -0700)
dns/rdtypes/svcbbase.py
tests/test_svcb.py

index 585c05e0e1964a015a12e339973d678262667969..b8b405944cc0f572d7514f828de2b615049a4647 100644 (file)
@@ -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]
index ff8dead6cf73df58842c18a6f386cfbf5a91360a..51126df9b516f4dfc63b8dc27d0721d81dc48645 100644 (file)
@@ -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')