From 717802860dc060860d55c3a0478cace6a5fc4b30 Mon Sep 17 00:00:00 2001 From: shortcutme Date: Sat, 16 Mar 2019 02:31:49 +0100 Subject: [PATCH] Create new unpacker object if client sending new-style, bin-type compatible msgpack streams --- src/Connection/Connection.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Connection/Connection.py b/src/Connection/Connection.py index b7f828f2..2b3f61d2 100644 --- a/src/Connection/Connection.py +++ b/src/Connection/Connection.py @@ -398,6 +398,15 @@ class Connection(object): else: self.port = int(handshake["fileserver_port"]) # Set peer fileserver port + if handshake.get("use_bin_type") and self.unpacker: + unprocessed_bytes_num = self.getUnpackerUnprocessedBytesNum() + self.log("Changing unpacker to bin type (unprocessed bytes: %s)" % unprocessed_bytes_num) + unprocessed_bytes = self.unpacker.read_bytes(unprocessed_bytes_num) + self.unpacker = self.getMsgpackUnpacker() # Create new unpacker for different msgpack type + self.unpacker_bytes = 0 + if unprocessed_bytes: + self.unpacker.feed(unprocessed_bytes) + # Check if we can encrypt the connection if handshake.get("crypt_supported") and self.ip not in self.server.broken_ssl_ips: if type(handshake["crypt_supported"][0]) is bytes: