Skip to content

Commit

Permalink
Limit maximum control frame length
Browse files Browse the repository at this point in the history
Adopt C fstrm limit of 512 bytes, not including type+length.
  • Loading branch information
cmikk committed Sep 8, 2020
1 parent 22acee6 commit bde1d9b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Control.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ const CONTROL_FINISH = 0x05

const CONTROL_FIELD_CONTENT_TYPE = 0x01

const CONTROL_FRAME_LENGTH_MAX = 512

type ControlFrame struct {
ControlType uint32
ContentTypes [][]byte
Expand Down Expand Up @@ -75,6 +77,14 @@ func (c *ControlFrame) Decode(r io.Reader) (err error) {
return
}

if cflen > CONTROL_FRAME_LENGTH_MAX {
return ErrDecode
}

if cflen < 4 {
return ErrDecode
}

err = binary.Read(r, binary.BigEndian, &c.ControlType)
if err != nil {
return
Expand Down

0 comments on commit bde1d9b

Please sign in to comment.