From: Bob Halley Date: Tue, 28 Aug 2012 20:51:59 +0000 (-0700) Subject: Do not generate empty NSEC3 bitmap windows X-Git-Tag: v1.11.0~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b05d56031c7ff6bceca4ed8788d49fe8b04a7da6;p=thirdparty%2Fdnspython.git Do not generate empty NSEC3 bitmap windows --- diff --git a/ChangeLog b/ChangeLog index 81650fed..8dc39d03 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2012-08-28 Bob Halley + + * dns/rdtypes/ANY/NSEC3.py (NSEC3.from_text): The NSEC3 from_text() + method could erroneously emit empty bitmap windows (i.e. windows + with a count of 0 bytes); such bitmaps are illegal. + 2012-04-08 Bob Halley * (Version 1.10.0 released) diff --git a/dns/rdtypes/ANY/NSEC3.py b/dns/rdtypes/ANY/NSEC3.py index c7ac7375..b42fe4c8 100644 --- a/dns/rdtypes/ANY/NSEC3.py +++ b/dns/rdtypes/ANY/NSEC3.py @@ -114,7 +114,8 @@ class NSEC3(dns.rdata.Rdata): prior_rdtype = nrdtype new_window = nrdtype // 256 if new_window != window: - windows.append((window, ''.join(bitmap[0:octets]))) + if octets != 0: + windows.append((window, ''.join(bitmap[0:octets]))) bitmap = ['\0'] * 32 window = new_window offset = nrdtype % 256 @@ -122,7 +123,8 @@ class NSEC3(dns.rdata.Rdata): bit = offset % 8 octets = byte + 1 bitmap[byte] = chr(ord(bitmap[byte]) | (0x80 >> bit)) - windows.append((window, ''.join(bitmap[0:octets]))) + if octets != 0: + windows.append((window, ''.join(bitmap[0:octets]))) return cls(rdclass, rdtype, algorithm, flags, iterations, salt, next, windows) from_text = classmethod(from_text) diff --git a/tests/bugs.py b/tests/bugs.py index c2fa6b66..312ec3ef 100644 --- a/tests/bugs.py +++ b/tests/bugs.py @@ -40,5 +40,10 @@ class BugsTestCase(unittest.TestCase): ttl = dns.ttl.from_text("2147483648") self.failUnlessRaises(dns.ttl.BadTTL, bad) + def test_empty_NSEC3_window(self): + rdata = dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.NSEC3, + "1 0 100 ABCD SCBCQHKU35969L2A68P3AD59LHF30715") + self.failUnless(rdata.windows == []) + if __name__ == '__main__': unittest.main()