mirror of
https://github.com/ammaraskar/pyCraft.git
synced 2024-11-16 07:15:24 +01:00
deal with faulty compression's
This commit is contained in:
parent
89a1bfb796
commit
357340e6dc
@ -436,14 +436,23 @@ class PacketReactor(object):
|
||||
|
||||
if self.connection.options.compression_enabled:
|
||||
decompressed_size = VarInt.read(packet_data)
|
||||
rawPacketData = None
|
||||
try:
|
||||
if decompressed_size > 0:
|
||||
decompressed_packet = decompress(packet_data.read())
|
||||
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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user