fix: Filter slice index out of bounds

This commit is contained in:
Hellojack 2023-02-26 13:04:12 +08:00 committed by GitHub
parent 0a6705f43e
commit 2cbfac2c89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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" {