From fc26c19e57faa7b22e76954e1d5243c82374125e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ale=C5=A1=20Smodi=C5=A1?= Date: Tue, 15 Sep 2015 12:19:38 +0200 Subject: Bugfix: invert the packet length comparison in the TCP packet decode loop. --- server/socket.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server/socket.py b/server/socket.py index b184d4b..ce505e3 100644 --- a/server/socket.py +++ b/server/socket.py @@ -109,10 +109,10 @@ class JsonClientSocket(SocketHandler): self.address = address socket.setblocking(False) self.status = 0 # registering - self.receiving_header = True - self.buffer = [] + self.receiving_header = True # whether we're receiving the length of the next packet, or the packet itself + self.buffer = [] # chunks of the next packet (header or body) self.received_length = 0 # the cumulative length of strings in buffer - self.body_length = 0 # the length of the next packet, given in the header + self.body_length = 0 # the length of the next packet, which was given in the header self._read_lock = threading.Lock() self._write_lock = threading.Lock() @@ -144,7 +144,7 @@ class JsonClientSocket(SocketHandler): offset = i + 1 self.receiving_header = False continue - elif (self.received_length + N - offset) <= self.body_length: + elif (self.received_length + N - offset) >= self.body_length: if self.received_length == 0: # an optimized case s = data[offset:offset+self.body_length] -- cgit v1.2.1