diff options
author | Bob Halley <halley@dnspython.org> | 2014-06-18 16:13:39 -0700 |
---|---|---|
committer | Bob Halley <halley@dnspython.org> | 2014-06-18 16:13:39 -0700 |
commit | b2dac7593f03793f7695a8e137d26a0a25140b44 (patch) | |
tree | c0a5c2949b17b2d68a69a8f3bf4ed53644821360 | |
parent | 2671293f470d998093d1ba0abe699591676fb951 (diff) | |
download | dnspython-b2dac7593f03793f7695a8e137d26a0a25140b44.tar.gz |
Allow empty APL RR.
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | dns/rdtypes/IN/APL.py | 4 | ||||
-rw-r--r-- | tests/test_bugs.py | 7 |
3 files changed, 15 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() 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() |