fix race condition when dropping Initial packet with short connection ID (#4236)

This commit is contained in:
Marten Seemann 2024-01-05 09:59:39 +07:00 committed by GitHub
parent 54d6f7dc51
commit f1b3bdbcb0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -542,10 +542,10 @@ func (s *baseServer) validateToken(token *handshake.Token, addr net.Addr) bool {
func (s *baseServer) handleInitialImpl(p receivedPacket, hdr *wire.Header) error {
if len(hdr.Token) == 0 && hdr.DestConnectionID.Len() < protocol.MinConnectionIDLenInitial {
p.buffer.Release()
if s.tracer != nil && s.tracer.DroppedPacket != nil {
s.tracer.DroppedPacket(p.remoteAddr, logging.PacketTypeInitial, p.Size(), logging.PacketDropUnexpectedPacket)
}
p.buffer.Release()
return errors.New("too short connection ID")
}