mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-04 04:37:36 +03:00
reject a header if the 0x40 bit of the first bit is not set
This doesn't apply to the version negotiation packet.
This commit is contained in:
parent
9c07ac15b8
commit
4145bcc8a7
2 changed files with 25 additions and 1 deletions
|
@ -2,6 +2,7 @@ package wire
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"io"
|
||||
|
||||
"github.com/lucas-clemente/quic-go/internal/protocol"
|
||||
|
@ -42,7 +43,6 @@ func ParseHeader(b *bytes.Reader, shortHeaderConnIDLen int) (*Header, error) {
|
|||
return h, nil
|
||||
}
|
||||
|
||||
// TODO: check that typeByte&0x40 == 0
|
||||
func parseHeaderImpl(b *bytes.Reader, shortHeaderConnIDLen int) (*Header, error) {
|
||||
typeByte, err := b.ReadByte()
|
||||
if err != nil {
|
||||
|
@ -55,6 +55,9 @@ func parseHeaderImpl(b *bytes.Reader, shortHeaderConnIDLen int) (*Header, error)
|
|||
}
|
||||
|
||||
if !h.IsLongHeader {
|
||||
if h.typeByte&0x40 == 0 {
|
||||
return nil, errors.New("not a QUIC packet")
|
||||
}
|
||||
if err := h.parseShortHeader(b, shortHeaderConnIDLen); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -78,6 +81,9 @@ func (h *Header) parseLongHeader(b *bytes.Reader) error {
|
|||
return err
|
||||
}
|
||||
h.Version = protocol.VersionNumber(v)
|
||||
if !h.IsVersionNegotiation() && h.typeByte&0x40 == 0 {
|
||||
return errors.New("not a QUIC packet")
|
||||
}
|
||||
connIDLenByte, err := b.ReadByte()
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue