]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
Dnspython was erroneously doing case-insensitive comparisons of the names in NSEC...
authorBob Halley <halley@nominum.com>
Wed, 9 Feb 2011 09:15:06 +0000 (09:15 +0000)
committerBob Halley <halley@nominum.com>
Wed, 9 Feb 2011 09:15:06 +0000 (09:15 +0000)
ChangeLog
dns/rdata.py
dns/rdtypes/ANY/NSEC.py
dns/rdtypes/ANY/SIG.py
dns/rdtypes/sigbase.py

index 0fff77f9777a8fffda34780dae862fd98397f5eb..73452c2a8e6c74db5f645454758cea98b73ea85e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2011-01-11  Bob Halley  <halley@dnspython.org>
+
+       * Dnspython was erroneously doing case-insensitive comparisons
+         of the names in NSEC and RRSIG RRs.  Thanks to Casey Deccio for
+         reporting this bug.
+
 2010-12-17  Bob Halley  <halley@dnspython.org>
 
        * dns/message.py (_WireReader._get_section): use "is" and not "=="
index 399677e984d697631d785802da58c2711751bb93..b4b92515f17864b74cfa9131ea032dacdc9ee92b 100644 (file)
@@ -256,6 +256,15 @@ class Rdata(object):
     def __hash__(self):
         return hash(self.to_digestable(dns.name.root))
 
+    def _wire_cmp(self, other):
+        # A number of types compare rdata in wire form, so we provide
+        # the method here instead of duplicating it.
+        b1 = cStringIO.StringIO()
+        self.to_wire(b1)
+        b2 = cStringIO.StringIO()
+        other.to_wire(b2)
+        return cmp(b1.getvalue(), b2.getvalue())
+
     def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True):
         """Build an rdata object from text format.
 
index 72859ce108a883a0bcbcc4fd8ae185d7aea433f3..44ccbc1b0bb0151d4a4826d363fb5e351c13e04a 100644 (file)
@@ -125,17 +125,4 @@ class NSEC(dns.rdata.Rdata):
         self.next = self.next.choose_relativity(origin, relativize)
 
     def _cmp(self, other):
-        v = cmp(self.next, other.next)
-        if v == 0:
-            b1 = cStringIO.StringIO()
-            for (window, bitmap) in self.windows:
-                b1.write(chr(window))
-                b1.write(chr(len(bitmap)))
-                b1.write(bitmap)
-            b2 = cStringIO.StringIO()
-            for (window, bitmap) in other.windows:
-                b2.write(chr(window))
-                b2.write(chr(len(bitmap)))
-                b2.write(bitmap)
-            v = cmp(b1.getvalue(), b2.getvalue())
-        return v
+        return self._wire_cmp(other)
index 501e29cc8c596bf6d005971e3a889548e2af6501..adcb733d640fd9c43c4e27ad82b8a0fbcb7ea2c3 100644 (file)
@@ -24,3 +24,18 @@ class SIG(dns.rdtypes.sigbase.SIGBase):
                            self.inception, self.key_tag) + \
                            self.signer.to_digestable(origin) + \
                            self.signature
+    def _cmp(self, other):
+        hs = struct.pack('!HBBIIIH', self.type_covered,
+                         self.algorithm, self.labels,
+                         self.original_ttl, self.expiration,
+                         self.inception, self.key_tag)
+        ho = struct.pack('!HBBIIIH', other.type_covered,
+                         other.algorithm, other.labels,
+                         other.original_ttl, other.expiration,
+                         other.inception, other.key_tag)
+        v = cmp(hs, ho)
+        if v == 0:
+            v = cmp(self.signer, other.signer)
+            if v == 0:
+                v = cmp(self.signature, other.signature)
+        return v
index ccb6dd69ae78f26c1bd80c366a1f13e4b3525387..81ca31e95e3b1d4e99349d926b6e518c91637f1f 100644 (file)
@@ -152,17 +152,4 @@ class SIGBase(dns.rdata.Rdata):
         self.signer = self.signer.choose_relativity(origin, relativize)
 
     def _cmp(self, other):
-        hs = struct.pack('!HBBIIIH', self.type_covered,
-                         self.algorithm, self.labels,
-                         self.original_ttl, self.expiration,
-                         self.inception, self.key_tag)
-        ho = struct.pack('!HBBIIIH', other.type_covered,
-                         other.algorithm, other.labels,
-                         other.original_ttl, other.expiration,
-                         other.inception, other.key_tag)
-        v = cmp(hs, ho)
-        if v == 0:
-            v = cmp(self.signer, other.signer)
-            if v == 0:
-                v = cmp(self.signature, other.signature)
-        return v
+        return self._wire_cmp(other)