Fix errors caused by the "uncompressed data length" field of compressed packets being erroneously written as the compressed data length.
This commit is contained in:
1 parent
c4ed8e6d68
commit
03565e24c8
2 files changed
+12
-10
No files matched your search
@@ -335,11 +335,12 @@ class PacketReactor(object):
|
|||||||
packet_data.reset_cursor()
|
packet_data.reset_cursor()
|
||||||
|
|
||||||
if self.connection.options.compression_enabled:
|
if self.connection.options.compression_enabled:
|
||||||
compressed_size = VarInt.read(packet_data)
|
decompressed_size = VarInt.read(packet_data)
|
||||||
|
if decompressed_size > 0:
|
||||||
if compressed_size > 0:
|
decompressed_packet = decompress(packet_data.read())
|
||||||
decompressed_packet = decompress(
|
assert len(decompressed_packet) == decompressed_size, \
|
||||||
packet_data.read(compressed_size))
|
'decompressed length %d, but expected %d' % \
|
||||||
|
(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()
|
||||||
|
|||||||
@@ -18,10 +18,10 @@ class PacketBuffer(object):
|
|||||||
"""
|
"""
|
||||||
self.bytes.write(value)
|
self.bytes.write(value)
|
||||||
|
|
||||||
def read(self, length):
|
def read(self, length=None):
|
||||||
return self.bytes.read(length)
|
return self.bytes.read(length)
|
||||||
|
|
||||||
def recv(self, length):
|
def recv(self, length=None):
|
||||||
return self.read(length)
|
return self.read(length)
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
@@ -123,10 +123,11 @@ class Packet(object):
|
|||||||
if compression_threshold is not None:
|
if compression_threshold is not None:
|
||||||
if len(packet_buffer.get_writable()) > compression_threshold != -1:
|
if len(packet_buffer.get_writable()) > compression_threshold != -1:
|
||||||
# compress the current payload
|
# compress the current payload
|
||||||
compressed_data = compress(packet_buffer.get_writable())
|
packet_data = packet_buffer.get_writable()
|
||||||
|
compressed_data = compress(packet_data)
|
||||||
packet_buffer.reset()
|
packet_buffer.reset()
|
||||||
# write out the length of the compressed payload
|
# write out the length of the uncompressed payload
|
||||||
VarInt.send(len(compressed_data), packet_buffer)
|
VarInt.send(len(packet_data), packet_buffer)
|
||||||
# write the compressed payload itself
|
# write the compressed payload itself
|
||||||
packet_buffer.send(compressed_data)
|
packet_buffer.send(compressed_data)
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in new issue
Block a user