From 2cbfac2c89b77b654f4468bf515cb3b115ed650c Mon Sep 17 00:00:00 2001 From: Hellojack <106379370+H1JK@users.noreply.github.com> Date: Sun, 26 Feb 2023 13:04:12 +0800 Subject: [PATCH] fix: Filter slice index out of bounds --- transport/vless/filter.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/transport/vless/filter.go b/transport/vless/filter.go index 5e00b5c3..099d2de1 100644 --- a/transport/vless/filter.go +++ b/transport/vless/filter.go @@ -51,14 +51,18 @@ func (vc *Conn) FilterTLS(p []byte) (index int) { if vc.remainingServerHello > 0 { end := int(vc.remainingServerHello) - if index+end > lenP { + i := index + if i < 0 { + i = 0 + } + if i+end > lenP { end = lenP - vc.remainingServerHello -= uint16(end - index) + vc.remainingServerHello -= uint16(end - i) } else { vc.remainingServerHello -= uint16(end) - end += index + end += i } - if bytes.Contains(p[index:end], tls13SupportedVersions) { + if bytes.Contains(p[i:end], tls13SupportedVersions) { // TLS 1.3 Client Hello cs, ok := tls13CipherSuiteMap[vc.cipher] if ok && cs != "TLS_AES_128_CCM_8_SHA256" {