From f1b3bdbcb046b51c05a09154d5d420298f6a398d Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Fri, 5 Jan 2024 09:59:39 +0700 Subject: [PATCH] fix race condition when dropping Initial packet with short connection ID (#4236) --- server.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server.go b/server.go index 124e30be..f509ae14 100644 --- a/server.go +++ b/server.go @@ -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") }