]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
Allow empty APL RR.
authorBob Halley <halley@dnspython.org>
Wed, 18 Jun 2014 23:13:39 +0000 (16:13 -0700)
committerBob Halley <halley@dnspython.org>
Wed, 18 Jun 2014 23:13:39 +0000 (16:13 -0700)
ChangeLog
dns/rdtypes/IN/APL.py
tests/test_bugs.py

index 9ee3bf73e92f160967188f34af77866c69924e31..fcf2f821c54f5d53167ec7eadd041406f1bae7f3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2014-06-18  Bob Halley  <halley@dnspython.org>
+
+    * dns/rdtypes/IN/APL.py: The APL from_wire() method did not accept an
+      rdata length of 0 as valid.  Thanks to salzmdan for reporting the
+      problem.
+
 2014-05-31  Bob Halley  <halley@dnspython.org>
 
        * dns/ipv6.py: Add is_mapped()
index 260fd6f39fc8e2dbb0033cbbcad566d6e809c0c4..59da75b9f43371ad659395ab046d63e870b862a7 100644 (file)
@@ -118,6 +118,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])
@@ -151,8 +153,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 312ec3ef85e32fe47a1a53f9c100d7e7e9b4b130..cee875750f2a2c5d3ff309e81669e0d7c454f529 100644 (file)
@@ -45,5 +45,12 @@ class BugsTestCase(unittest.TestCase):
                                     "1 0 100 ABCD SCBCQHKU35969L2A68P3AD59LHF30715")
         self.failUnless(rdata.windows == [])
 
+    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,
+                                     "", 0, 0)
+        self.failUnless(rdata == rdata2)
+
 if __name__ == '__main__':
     unittest.main()