# HG changeset patch # User Brendan Cully # Date 2010-02-07 18:39:29 # Node ID 1ddb0ae26a55989b72bed9239ef641000931ed7d # Parent 3dfc6b2cf916a2d2cbea12e0485ef167094e076c zeroconf: better fix for readName error Stop parsing when an unknown type is seen, since it is impossible to resynchronize on the stream. diff --git a/hgext/zeroconf/Zeroconf.py b/hgext/zeroconf/Zeroconf.py --- a/hgext/zeroconf/Zeroconf.py +++ b/hgext/zeroconf/Zeroconf.py @@ -560,7 +560,7 @@ class DNSIncoming(object): # #print "UNKNOWN TYPE = " + str(info[0]) #raise BadTypeInNameException - pass + break if rec is not None: self.answers.append(rec) @@ -575,11 +575,7 @@ class DNSIncoming(object): def readUTF(self, offset, len): """Reads a UTF-8 string of a given length from the packet""" - result = self.data[offset:offset+len] - try: - return result.decode('utf-8') - except UnicodeDecodeError: - return result.decode('utf-16') + return self.data[offset:offset+len].decode('utf-8') def readName(self): """Reads a domain name from the packet"""