From 877f0470c50d7a9b42e1f7caf3e572d1a55bd717 Mon Sep 17 00:00:00 2001 From: BreakWa11 Date: Sun, 8 Nov 2015 23:35:04 +0800 Subject: [PATCH] http_simple: fix no response in some case verify_simple: check package size minimum 7 bytes --- shadowsocks/obfsplugin/http_simple.py | 5 +++-- shadowsocks/obfsplugin/verify_simple.py | 12 ++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/shadowsocks/obfsplugin/http_simple.py b/shadowsocks/obfsplugin/http_simple.py index ad782ee..1edf121 100644 --- a/shadowsocks/obfsplugin/http_simple.py +++ b/shadowsocks/obfsplugin/http_simple.py @@ -171,9 +171,10 @@ class http_simple(plain.plain): return (b'', True, False) datas = buf.split(b'\r\n\r\n', 1) - if datas and len(datas) > 1: + if datas: ret_buf = self.get_data_from_http_header(buf) - ret_buf += datas[1] + if len(datas) > 1: + ret_buf += datas[1] if len(ret_buf) >= 15: self.has_recv_header = True return (ret_buf, True, False) diff --git a/shadowsocks/obfsplugin/verify_simple.py b/shadowsocks/obfsplugin/verify_simple.py index 8945d96..03c73b2 100644 --- a/shadowsocks/obfsplugin/verify_simple.py +++ b/shadowsocks/obfsplugin/verify_simple.py @@ -126,7 +126,7 @@ class verify_simple(verify_base): out_buf = b'' while len(self.recv_buf) > 2: length = struct.unpack('>H', self.recv_buf[:2])[0] - if length >= 8192: + if length >= 8192 or length < 7: self.raw_trans = True self.recv_buf = b'' if self.decrypt_packet_num == 0: @@ -167,7 +167,7 @@ class verify_simple(verify_base): out_buf = b'' while len(self.recv_buf) > 2: length = struct.unpack('>H', self.recv_buf[:2])[0] - if length >= 8192: + if length >= 8192 or length < 7: self.raw_trans = True self.recv_buf = b'' if self.decrypt_packet_num == 0: @@ -223,7 +223,7 @@ class verify_deflate(verify_base): out_buf = b'' while len(self.recv_buf) > 2: length = struct.unpack('>H', self.recv_buf[:2])[0] - if length >= 32768: + if length >= 32768 or length < 6: self.raw_trans = True self.recv_buf = b'' if self.decrypt_packet_num == 0: @@ -255,7 +255,7 @@ class verify_deflate(verify_base): out_buf = b'' while len(self.recv_buf) > 2: length = struct.unpack('>H', self.recv_buf[:2])[0] - if length >= 32768: + if length >= 32768 or length < 6: self.raw_trans = True self.recv_buf = b'' if self.decrypt_packet_num == 0: @@ -424,7 +424,7 @@ class auth_simple(verify_base): out_buf = b'' while len(self.recv_buf) > 2: length = struct.unpack('>H', self.recv_buf[:2])[0] - if length >= 8192: + if length >= 8192 or length < 7: self.raw_trans = True self.recv_buf = b'' if self.decrypt_packet_num == 0: @@ -465,7 +465,7 @@ class auth_simple(verify_base): out_buf = b'' while len(self.recv_buf) > 2: length = struct.unpack('>H', self.recv_buf[:2])[0] - if length >= 8192: + if length >= 8192 or length < 7: self.raw_trans = True self.recv_buf = b'' if self.decrypt_packet_num == 0: