diff --git a/Control.go b/Control.go index 3f04cde..f4f9f6f 100644 --- a/Control.go +++ b/Control.go @@ -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 @@ -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