From 5ba75492f115ac7e747957f2b00e29b6c560c797 Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Thu, 18 Dec 2014 11:03:22 -0800 Subject: Fix reading headers of large packets If it takes more than one pass through readPacket to collect the entirety of a packet, we would not correctly read the header after the first pass. This ensures that any time the packet is at least long enough for a header, it is decoded. Change-Id: I210bed20da3005298765ce22826e26539d085125 --- gear/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gear') diff --git a/gear/__init__.py b/gear/__init__.py index 7113ab5..76b5b16 100644 --- a/gear/__init__.py +++ b/gear/__init__.py @@ -315,9 +315,9 @@ class Connection(object): packet = b'' return admin_request else: - if len(packet) == 12: + if code is None and len(packet) >= 12: code, ptype, datalen = struct.unpack('!4sii', - packet) + packet[:12]) if len(packet) == datalen + 12: p = Packet(code, ptype, packet[12:], connection=self) -- cgit v1.2.1