]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
Do not generate empty NSEC3 bitmap windows
authorBob Halley <halley@dnspython.org>
Tue, 28 Aug 2012 20:58:33 +0000 (13:58 -0700)
committerBob Halley <halley@dnspython.org>
Tue, 28 Aug 2012 20:58:33 +0000 (13:58 -0700)
ChangeLog
dns/rdtypes/ANY/NSEC3.py
tests/bugs.py

index 46609f5cdcf45fbf9bb3c4529026f4020eeed59c..bae1b34869b1db996c65d29d90bcc49c17dec7ab 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2012-08-28  Bob Halley  <halley@dnspython.org>
+
+       * 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-10  Bob Halley  <halley@dnspython.org>
 
        * dns/dnssec.py (_validate_rrsig): Fix python3 port issues with
index df2dbff486859589251b7189c86848aae80254de..76a28671639277abac03a4f9497ac589de616836 100644 (file)
@@ -117,7 +117,8 @@ class NSEC3(dns.rdata.Rdata):
             prior_rdtype = nrdtype
             new_window = nrdtype // 256
             if new_window != window:
-                windows.append((window, bytes(bitmap[0:octets])))
+                if octets != 0:
+                    windows.append((window, bytes(bitmap[0:octets])))
                 bitmap = bytearray(32)
                 window = new_window
             offset = nrdtype % 256
@@ -125,7 +126,8 @@ class NSEC3(dns.rdata.Rdata):
             bit = offset % 8
             octets = byte + 1
             bitmap[byte] = bitmap[byte] | (0x80 >> bit)
-        windows.append((window, bytes(bitmap[0:octets])))
+        if octets != 0:
+            windows.append((window, bytes(bitmap[0:octets])))
         return cls(rdclass, rdtype, algorithm, flags, iterations, salt, next, windows)
 
     from_text = classmethod(from_text)
index fb008448c194530773c39470fb569753cbe01be5..dd18f3179c65ca611af9146506ad6e06c996762e 100644 (file)
@@ -40,5 +40,10 @@ class BugsTestCase(unittest.TestCase):
             ttl = dns.ttl.from_text("2147483648")
         self.assertRaises(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.assertTrue(rdata.windows == [])
+
 if __name__ == '__main__':
     unittest.main()