From 3b0200581ca9487e5796511dd38029dc4f926c48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A0=B4=E5=A8=83=E9=85=B1?= Date: Sat, 20 May 2017 18:39:26 +0800 Subject: [PATCH] refine error detector --- shadowsocks/obfsplugin/obfs_tls.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/shadowsocks/obfsplugin/obfs_tls.py b/shadowsocks/obfsplugin/obfs_tls.py index e489911..c235478 100644 --- a/shadowsocks/obfsplugin/obfs_tls.py +++ b/shadowsocks/obfsplugin/obfs_tls.py @@ -241,12 +241,13 @@ class tls_ticket_auth(plain.plain): if not match_begin(buf, b'\x16\x03\x01'): return self.decode_error_return(ogn_buf) buf = buf[3:] - if struct.unpack('>H', buf[:2])[0] > len(buf) - 2: + header_len = struct.unpack('>H', buf[:2])[0] + if header_len > len(buf) - 2: return (b'', False, False) - self.recv_buffer = self.recv_buffer[struct.unpack('>H', buf[:2])[0] + 5:] + self.recv_buffer = self.recv_buffer[header_len + 5:] self.handshake_status = 2 - buf = buf[2:] + buf = buf[2:header_len + 2] if not match_begin(buf, b'\x01\x00'): #client hello logging.info("tls_auth not client hello message") return self.decode_error_return(ogn_buf)