forked from quic-go/quic-go
add a bug check for consistent payload length in the packet packer
This commit is contained in:
@@ -546,6 +546,9 @@ func (p *packetPacker) writeAndSealPacketWithPadding(
|
||||
}
|
||||
}
|
||||
|
||||
if payloadSize := protocol.ByteCount(buffer.Len()-payloadOffset) - paddingLen; payloadSize != payload.length {
|
||||
return nil, fmt.Errorf("PacketPacker BUG: payload size inconsistent (expected %d, got %d bytes)", payload.length, payloadSize)
|
||||
}
|
||||
if size := protocol.ByteCount(buffer.Len() + sealer.Overhead()); size > p.maxPacketSize {
|
||||
return nil, fmt.Errorf("PacketPacker BUG: packet too large (%d bytes, allowed %d bytes)", size, p.maxPacketSize)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user