+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 "=="
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.
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)
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
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)