mirror of
https://github.com/ammaraskar/pyCraft.git
synced 2024-11-16 15:25:12 +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:
|
if self.connection.options.compression_enabled:
|
||||||
decompressed_size = VarInt.read(packet_data)
|
decompressed_size = VarInt.read(packet_data)
|
||||||
|
rawPacketData = None
|
||||||
|
try:
|
||||||
if decompressed_size > 0:
|
if decompressed_size > 0:
|
||||||
decompressed_packet = decompress(packet_data.read())
|
rawPacketData = packet_data.read()
|
||||||
|
decompressed_packet = decompress(rawPacketData)
|
||||||
assert len(decompressed_packet) == decompressed_size, \
|
assert len(decompressed_packet) == decompressed_size, \
|
||||||
'decompressed length %d, but expected %d' % \
|
'decompressed length %d, but expected %d' % \
|
||||||
(len(decompressed_packet), decompressed_size)
|
(len(decompressed_packet), decompressed_size)
|
||||||
packet_data.reset()
|
packet_data.reset()
|
||||||
packet_data.send(decompressed_packet)
|
packet_data.send(decompressed_packet)
|
||||||
packet_data.reset_cursor()
|
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)
|
packet_id = VarInt.read(packet_data)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user