This commit is contained in:
Kovid Goyal 2014-07-15 13:43:30 +05:30
commit 245050d593

View File

@ -199,6 +199,9 @@ def address_type(address):
# Exceptions # Exceptions
class MalformedPacketException(Exception):
pass
class NonLocalNameException(Exception): class NonLocalNameException(Exception):
pass pass
@ -595,6 +598,7 @@ class DNSIncoming(object):
first = off first = off
while 1: while 1:
try:
len = ord(self.data[off]) len = ord(self.data[off])
off += 1 off += 1
if len == 0: if len == 0:
@ -612,6 +616,8 @@ class DNSIncoming(object):
first = off first = off
else: else:
raise BadDomainName(off) raise BadDomainName(off)
except IndexError:
raise MalformedPacketException()
if next >= 0: if next >= 0:
self.offset = next self.offset = next
@ -876,6 +882,8 @@ class Engine(threading.Thread):
for sock in rr: for sock in rr:
try: try:
self.readers[sock].handle_read() self.readers[sock].handle_read()
except MalformedPacketException:
pass
except: except:
if DEBUG: if DEBUG:
traceback.print_exc() traceback.print_exc()