drop Initial packets that don't fulfill the min size requirement

This commit is contained in:
Marten Seemann
2017-12-08 12:37:04 +07:00
parent 23ce5a8554
commit ef89e7aa17
2 changed files with 17 additions and 3 deletions

View File

@@ -2,6 +2,7 @@ package quic
import (
"crypto/tls"
"errors"
"fmt"
"net"
@@ -98,7 +99,9 @@ func (s *serverTLS) newMintConnImpl(bc *handshake.CryptoStreamConn, v protocol.V
}
func (s *serverTLS) handleInitialImpl(remoteAddr net.Addr, hdr *wire.Header, data []byte) (packetHandler, error) {
// TODO: check length requirement
if len(hdr.Raw)+len(data) < protocol.MinInitialPacketSize {
return nil, errors.New("dropping too small Initial packet")
}
// check version, if not matching send VNP
if !protocol.IsSupportedVersion(s.supportedVersions, hdr.Version) {
utils.Debugf("Client offered version %s, sending VersionNegotiationPacket", hdr.Version)