fix length check for too short packets

This commit is contained in:
Marten Seemann
2018-12-29 19:41:07 +07:00
parent 673ad95a44
commit 99b1e50722
2 changed files with 9 additions and 2 deletions

View File

@@ -202,7 +202,7 @@ func (h *packetHandlerMap) parsePacket(
var rest []byte
if hdr.IsLongHeader {
if protocol.ByteCount(len(data)) < hdr.Length {
if protocol.ByteCount(len(data)) < hdr.ParsedLen()+hdr.Length {
return packets, fmt.Errorf("packet length (%d bytes) is smaller than the expected length (%d bytes)", len(data)-int(hdr.ParsedLen()), hdr.Length)
}
packetLen := int(hdr.ParsedLen() + hdr.Length)