forked from quic-go/quic-go
drop packets for new gQUIC connections that are too small
This commit is contained in:
@@ -328,7 +328,7 @@ func (s *server) handlePacket(pconn net.PacketConn, remoteAddr net.Addr, packet
|
||||
// since the client send a Public Header (only gQUIC has a Version Flag), we need to send a gQUIC Version Negotiation Packet
|
||||
if hdr.VersionFlag && !protocol.IsSupportedVersion(s.config.Versions, hdr.Version) {
|
||||
// drop packets that are too small to be valid first packets
|
||||
if len(packet) < protocol.ClientHelloMinimumSize+len(hdr.Raw) {
|
||||
if len(packet) < protocol.MinClientHelloSize+len(hdr.Raw) {
|
||||
return errors.New("dropping small packet with unknown version")
|
||||
}
|
||||
utils.Infof("Client offered version %s, sending VersionNegotiationPacket", hdr.Version)
|
||||
@@ -337,6 +337,12 @@ func (s *server) handlePacket(pconn net.PacketConn, remoteAddr net.Addr, packet
|
||||
}
|
||||
}
|
||||
|
||||
// This is (potentially) a Client Hello.
|
||||
// Make sure it has the minimum required size before spending any more ressources on it.
|
||||
if !sessionKnown && len(packet) < protocol.MinClientHelloSize+len(hdr.Raw) {
|
||||
return errors.New("dropping small packet for unknown connection")
|
||||
}
|
||||
|
||||
if !sessionKnown {
|
||||
version := hdr.Version
|
||||
if !protocol.IsSupportedVersion(s.config.Versions, version) {
|
||||
|
||||
Reference in New Issue
Block a user