summaryrefslogtreecommitdiff
path: root/gear
diff options
context:
space:
mode:
authorJames E. Blair <jeblair@hp.com>2014-12-18 11:03:22 -0800
committerJames E. Blair <jeblair@hp.com>2014-12-18 11:14:18 -0800
commit5ba75492f115ac7e747957f2b00e29b6c560c797 (patch)
tree41cd5d3ca1609f4d5c90f795f0431fd2ad029d7d /gear
parenta799a83e36b3cc7cbb45758ba7a9cae7dba4b65f (diff)
downloadgear-5ba75492f115ac7e747957f2b00e29b6c560c797.tar.gz
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
Diffstat (limited to 'gear')
-rw-r--r--gear/__init__.py4
1 files changed, 2 insertions, 2 deletions
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)