]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
Allow empty APL RR.
authorBob Halley <halley@dnspython.org>
Mon, 1 Sep 2014 00:14:05 +0000 (17:14 -0700)
committerBob Halley <halley@dnspython.org>
Mon, 1 Sep 2014 00:14:05 +0000 (17:14 -0700)
dns/rdtypes/IN/APL.py
tests/bugs.py

index a7b8510d2f5a75ad38d199afa78a30522d82f33b..58e35b662cc1e28f2d83a21d7533e80f5093b65e 100644 (file)
@@ -119,6 +119,8 @@ class APL(dns.rdata.Rdata):
     def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None):
         items = []
         while 1:
+            if rdlen == 0:
+                break
             if rdlen < 4:
                 raise dns.exception.FormError
             header = struct.unpack('!HBB', wire[current : current + 4])
@@ -152,8 +154,6 @@ class APL(dns.rdata.Rdata):
             rdlen -= afdlen
             item = APLItem(header[0], negation, address, header[1])
             items.append(item)
-            if rdlen == 0:
-                break
         return cls(rdclass, rdtype, items)
 
     from_wire = classmethod(from_wire)
index 79b30eb66e1a58f5c08be0884b046764f2ba2337..906e0fd87ad67c946a51308d1461a5c3d3d06fee 100644 (file)
@@ -52,5 +52,13 @@ class BugsTestCase(unittest.TestCase):
         out4 = rd4.to_digestable(dns.name.from_text("test"))
         self.assertTrue(binascii.hexlify(out4).decode('ascii') == '000101817f')
 
+    def test_zero_size_APL(self):
+        rdata = dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.APL,
+                                    "")
+        rdata2 = dns.rdata.from_wire(dns.rdataclass.IN, dns.rdatatype.APL,
+                                     b"", 0, 0)
+        self.assertTrue(rdata == rdata2)
+
+
 if __name__ == '__main__':
     unittest.main()