reject packets with version 0 sent by the client

Version 0 is an invalid version. For packets sent by the server, it is
used to identify the Version Negotiation Packet.
This commit is contained in:
Marten Seemann
2017-12-08 08:51:56 +07:00
parent 2b5573fe82
commit 62b0d99dcd
2 changed files with 14 additions and 0 deletions

View File

@@ -42,6 +42,9 @@ func parseLongHeader(b *bytes.Reader, sentBy protocol.Perspective, typeByte byte
Version: protocol.VersionNumber(v),
}
if v == 0 { // version negotiation packet
if sentBy == protocol.PerspectiveClient {
return nil, qerr.InvalidVersion
}
if b.Len() == 0 {
return nil, qerr.Error(qerr.InvalidVersionNegotiationPacket, "empty version list")
}