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