1
0
mirror of https://github.com/Mrs4s/MiraiGo.git synced 2025-05-05 03:23:50 +08:00

fix: panic with invalid packet length.

This commit is contained in:
Mrs4s 2021-10-14 21:44:48 +08:00
parent a3eacd706b
commit d2c218e92b
No known key found for this signature in database
GPG Key ID: 3186E98FA19CE3A7

View File

@ -191,6 +191,14 @@ func (c *QQClient) netLoop() {
time.Sleep(time.Millisecond * 500) time.Sleep(time.Millisecond * 500)
continue continue
} }
if l <= 0 || l > 1024*1024*10 { // max 10MB
c.Error("parse incoming packet error: invalid packet length %v", l)
errCount++
if errCount > 2 {
go c.quickReconnect()
}
continue
}
data, _ := c.TCP.ReadBytes(int(l) - 4) data, _ := c.TCP.ReadBytes(int(l) - 4)
pkt, err := packets.ParseIncomingPacket(data, c.sigInfo.d2Key) pkt, err := packets.ParseIncomingPacket(data, c.sigInfo.d2Key)
if err != nil { if err != nil {
@ -203,7 +211,6 @@ func (c *QQClient) netLoop() {
errCount++ errCount++
if errCount > 2 { if errCount > 2 {
go c.quickReconnect() go c.quickReconnect()
continue
} }
continue continue
} }