deal with faulty compression's

This commit is contained in:
TheSnoozer 2017-07-31 01:02:02 +02:00
parent 89a1bfb796
commit 357340e6dc

View File

@ -436,14 +436,23 @@ class PacketReactor(object):
if self.connection.options.compression_enabled:
decompressed_size = VarInt.read(packet_data)
if decompressed_size > 0:
decompressed_packet = decompress(packet_data.read())
assert len(decompressed_packet) == decompressed_size, \
'decompressed length %d, but expected %d' % \
(len(decompressed_packet), decompressed_size)
packet_data.reset()
packet_data.send(decompressed_packet)
packet_data.reset_cursor()
rawPacketData = None
try:
if decompressed_size > 0:
rawPacketData = packet_data.read()
decompressed_packet = decompress(rawPacketData)
assert len(decompressed_packet) == decompressed_size, \
'decompressed length %d, but expected %d' % \
(len(decompressed_packet), decompressed_size)
packet_data.reset()
packet_data.send(decompressed_packet)
packet_data.reset_cursor()
except:
if rawPacketData:
packet_data.reset()
packet_data.send(rawPacketData)
packet_data.reset_cursor()
pass
packet_id = VarInt.read(packet_data)