protcol/rtp: panic in Payload if length is not sufficiently long to be RTP packet.

This commit is contained in:
Saxon 2019-04-10 12:51:05 +09:30
parent f52272894a
commit ff0c62910c
1 changed files with 3 additions and 0 deletions

View File

@ -37,6 +37,9 @@ const badVer = "incompatible RTP version"
// Payload returns the payload from an RTP packet provided the version is // Payload returns the payload from an RTP packet provided the version is
// compatible, otherwise an error is returned. // compatible, otherwise an error is returned.
func Payload(d []byte) ([]byte, error) { func Payload(d []byte) ([]byte, error) {
if len(d) < defaultHeadSize {
panic("invalid RTP packet length")
}
if version(d) != rtpVer { if version(d) != rtpVer {
return nil, errors.New(badVer) return nil, errors.New(badVer)
} }