From fe8e98b9d8c54fee136bf9872d18c251a1a9a313 Mon Sep 17 00:00:00 2001 From: Mrs4s <1844812067@qq.com> Date: Sat, 22 Aug 2020 00:42:44 +0800 Subject: [PATCH] fix packet error. --- client/highway.go | 1 - protocol/packets/global.go | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/client/highway.go b/client/highway.go index 31739c6a..148e6c08 100644 --- a/client/highway.go +++ b/client/highway.go @@ -44,7 +44,6 @@ func (c *QQClient) highwayUploadImage(ip uint32, port int, updKey, img []byte, c hl, _ := r.ReadInt32() _, _ = r.ReadBytes(4) payload, _ := r.ReadBytes(int(hl)) - _ = conn.Close() rsp := new(pb.RspDataHighwayHead) if err = proto.Unmarshal(payload, rsp); err != nil { return err diff --git a/protocol/packets/global.go b/protocol/packets/global.go index d7ab7648..1984c3a0 100644 --- a/protocol/packets/global.go +++ b/protocol/packets/global.go @@ -8,6 +8,7 @@ import ( ) var ErrUnknownFlag = errors.New("unknown flag") +var ErrInvalidPayload = errors.New("invalid payload") var ErrDecryptFailed = errors.New("decrypt failed") type ISendingPacket interface { @@ -83,6 +84,9 @@ func BuildSsoPacket(seq uint16, commandName, imei string, extData, outPacketSess } func ParseIncomingPacket(payload, d2key []byte) (*IncomingPacket, error) { + if len(payload) < 6 { + return nil, ErrInvalidPayload + } reader := binary.NewReader(payload) flag1 := reader.ReadInt32() flag2 := reader.ReadByte()