mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 11:42:43 +08:00
fix: ssr panic
This commit is contained in:
parent
f794c090a5
commit
6cd0e58fd0
|
@ -7,6 +7,7 @@ import (
|
|||
"crypto/rc4"
|
||||
"encoding/base64"
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"net"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
@ -107,6 +108,10 @@ func (a *authChainA) Decode(dst, src *bytes.Buffer) error {
|
|||
dataLength := int(binary.LittleEndian.Uint16(src.Bytes()[:2]) ^ binary.LittleEndian.Uint16(a.lastServerHash[14:16]))
|
||||
randDataLength := a.randDataLength(dataLength, a.lastServerHash, &a.randomServer)
|
||||
length := dataLength + randDataLength
|
||||
// Temporary workaround for https://github.com/Dreamacro/clash/issues/1352
|
||||
if dataLength < 0 || randDataLength < 0 || length < 0 {
|
||||
return errors.New("ssr crashing blocked")
|
||||
}
|
||||
|
||||
if length >= 4096 {
|
||||
a.rawTrans = true
|
||||
|
@ -130,6 +135,11 @@ func (a *authChainA) Decode(dst, src *bytes.Buffer) error {
|
|||
if dataLength > 0 && randDataLength > 0 {
|
||||
pos += getRandStartPos(randDataLength, &a.randomServer)
|
||||
}
|
||||
// Temporary workaround for https://github.com/Dreamacro/clash/issues/1352
|
||||
if pos < 0 || pos+dataLength < 0 || dataLength < 0 {
|
||||
return errors.New("ssr crashing blocked")
|
||||
}
|
||||
|
||||
wantedData := src.Bytes()[pos : pos+dataLength]
|
||||
a.decrypter.XORKeyStream(wantedData, wantedData)
|
||||
if a.recvID == 1 {
|
||||
|
|
Loading…
Reference in New Issue
Block a user