From 4f28f7c8e409a06709bca4d8a805f6e6726fc089 Mon Sep 17 00:00:00 2001 From: loggerhead Date: Mon, 10 Oct 2016 23:05:20 +0800 Subject: [PATCH] Fix a OTA bug on `_ota_chunk_data` (#642) * fix a OTA bug * correct a wrong comment --- shadowsocks/tcprelay.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shadowsocks/tcprelay.py b/shadowsocks/tcprelay.py index 2e4772d..2ff7b21 100644 --- a/shadowsocks/tcprelay.py +++ b/shadowsocks/tcprelay.py @@ -358,7 +358,7 @@ class TCPRelayHandler(object): b'\x00\x00\x00\x00\x10\x10'), self._local_sock) # spec https://shadowsocks.org/en/spec/one-time-auth.html - # ATYP & 0x10 == 1, then OTA is enabled. + # ATYP & 0x10 == 0x10, then OTA is enabled. if self._ota_enable_session: data = common.chr(addrtype | ADDRTYPE_AUTH) + data[1:] key = self._encryptor.cipher_iv + self._encryptor.key @@ -458,7 +458,7 @@ class TCPRelayHandler(object): return data_len = self._ota_buff_head[:ONETIMEAUTH_CHUNK_DATA_LEN] self._ota_len = struct.unpack('>H', data_len)[0] - length = min(self._ota_len, len(data)) + length = min(self._ota_len - len(self._ota_buff_data), len(data)) self._ota_buff_data += data[:length] data = data[length:] if len(self._ota_buff_data) == self._ota_len: