changeset 10386:1ddb0ae26a55

zeroconf: better fix for readName error Stop parsing when an unknown type is seen, since it is impossible to resynchronize on the stream.
author Brendan Cully <brendan@kublai.com>
date Sun, 07 Feb 2010 19:39:29 +0100
parents 3dfc6b2cf916
children 9b87c5f4c634
files hgext/zeroconf/Zeroconf.py
diffstat 1 files changed, 2 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/zeroconf/Zeroconf.py	Sun Feb 07 18:37:14 2010 +0100
+++ b/hgext/zeroconf/Zeroconf.py	Sun Feb 07 19:39:29 2010 +0100
@@ -560,7 +560,7 @@
 				#
 				#print "UNKNOWN TYPE = " + str(info[0])
 				#raise BadTypeInNameException
-				pass
+				break
 
 			if rec is not None:
 				self.answers.append(rec)
@@ -575,11 +575,7 @@
 
 	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"""