From: Bob Halley Date: Thu, 23 Jul 2009 18:26:51 +0000 (-0700) Subject: Fix SRV record comparison X-Git-Tag: v1.8.0~25 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9b72d6bce1c6f85d8f8c341f5a206d8ed4f10b0f;p=thirdparty%2Fdnspython.git Fix SRV record comparison --- diff --git a/ChangeLog b/ChangeLog index 50f902ef..c75df5bb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,11 @@ 2009-07-23 Bob Halley - * dns/e164.py (query): The resolver parameter was never used. + * dns/rdtypes/IN/SRV.py (SRV._cmp): SRV records were compared + incorrectly due to a cut-and-paste error. Thanks to Tommie + Gannert for reporting this bug. + + * dns/e164.py (query): The resolver parameter was not used. + Thanks to Matías Bellone for reporting this bug. 2009-06-23 Bob Halley diff --git a/dns/rdtypes/IN/SRV.py b/dns/rdtypes/IN/SRV.py index 2689d7f9..2e78513d 100644 --- a/dns/rdtypes/IN/SRV.py +++ b/dns/rdtypes/IN/SRV.py @@ -33,7 +33,7 @@ class SRV(dns.rdata.Rdata): @see: RFC 2782""" __slots__ = ['priority', 'weight', 'port', 'target'] - + def __init__(self, rdclass, rdtype, priority, weight, port, target): super(SRV, self).__init__(rdclass, rdtype) self.priority = priority @@ -45,7 +45,7 @@ class SRV(dns.rdata.Rdata): target = self.target.choose_relativity(origin, relativize) return '%d %d %d %s' % (self.priority, self.weight, self.port, target) - + def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True): priority = tok.get_uint16() weight = tok.get_uint16() @@ -54,14 +54,14 @@ class SRV(dns.rdata.Rdata): target = target.choose_relativity(origin, relativize) tok.get_eol() return cls(rdclass, rdtype, priority, weight, port, target) - + from_text = classmethod(from_text) def to_wire(self, file, compress = None, origin = None): three_ints = struct.pack("!HHH", self.priority, self.weight, self.port) file.write(three_ints) self.target.to_wire(file, compress, origin) - + def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None): (priority, weight, port) = struct.unpack('!HHH', wire[current : current + 6]) @@ -82,7 +82,7 @@ class SRV(dns.rdata.Rdata): def _cmp(self, other): sp = struct.pack("!HHH", self.priority, self.weight, self.port) - op = struct.pack("!HHH", other.priority, self.weight, self.port) + op = struct.pack("!HHH", other.priority, other.weight, other.port) v = cmp(sp, op) if v == 0: v = cmp(self.target, other.target)