diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | Makefile | 5 | ||||
-rw-r--r-- | dns/rdtypes/IN/APL.py | 4 | ||||
-rw-r--r-- | tests/test_bugs.py | 7 |
4 files changed, 20 insertions, 2 deletions
@@ -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() @@ -54,3 +54,8 @@ kits: tags: find . -name '*.py' -print | etags - + +check: test + +test: + cd tests; make test diff --git a/dns/rdtypes/IN/APL.py b/dns/rdtypes/IN/APL.py index 260fd6f..59da75b 100644 --- a/dns/rdtypes/IN/APL.py +++ b/dns/rdtypes/IN/APL.py @@ -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) diff --git a/tests/test_bugs.py b/tests/test_bugs.py index 312ec3e..cee8757 100644 --- a/tests/test_bugs.py +++ b/tests/test_bugs.py @@ -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() |