1
0
mirror of https://github.com/Mrs4s/MiraiGo.git synced 2025-05-04 11:07:40 +08:00

fix highway memory leak

This commit is contained in:
Mrs4s 2022-01-18 00:50:08 +08:00
parent 38bb31b5a6
commit 3b461554b7
No known key found for this signature in database
GPG Key ID: 3186E98FA19CE3A7

View File

@ -28,6 +28,8 @@ type Session struct {
seq int32
}
const highwayMaxResponseSize int32 = 1024 * 100 // 100k
func (s *Session) AddrLength() int {
return len(s.SsoAddr)
}
@ -247,6 +249,9 @@ func readResponse(r *binary.NetworkReader) (*pb.RspDataHighwayHead, []byte, erro
}
hl, _ := r.ReadInt32()
a2, _ := r.ReadInt32()
if hl > highwayMaxResponseSize || a2 > highwayMaxResponseSize {
return nil, nil, errors.Errorf("highway response invild. head size: %v body size: %v", hl, a2)
}
head, _ := r.ReadBytes(int(hl))
payload, _ := r.ReadBytes(int(a2))
_, _ = r.ReadByte()