summaryrefslogtreecommitdiff
path: root/libavformat/rtpdec.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-01-21 14:55:48 +0100
committerMichael Niedermayer <michaelni@gmx.at>2013-01-21 14:55:48 +0100
commitacc0c0190bd6144d921397d53e928532a8d86de0 (patch)
treef7296da32f37597be3fd11bd4ac9fddf6037743a /libavformat/rtpdec.c
parentfbdb0313f53f84f5a8a5a23ad1880bf7ef4dcc5f (diff)
parentf53490cc0c809975f8238d5a9edbd26f83bd2f84 (diff)
Merge commit 'f53490cc0c809975f8238d5a9edbd26f83bd2f84'
* commit 'f53490cc0c809975f8238d5a9edbd26f83bd2f84': rtpdec/srtp: Handle CSRC fields being present rtpdec: Check the return value from av_new_packet ac3dec: fix non-optimal dithering of zero bit mantissas Conflicts: libavcodec/ac3dec.c libavformat/rtpdec.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/rtpdec.c')
-rw-r--r--libavformat/rtpdec.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c
index b7afc00b77..a1f17019fb 100644
--- a/libavformat/rtpdec.c
+++ b/libavformat/rtpdec.c
@@ -575,12 +575,12 @@ static int rtp_parse_packet_internal(RTPDemuxContext *s, AVPacket *pkt,
{
unsigned int ssrc;
int payload_type, seq, flags = 0;
- int ext;
+ int ext, csrc;
AVStream *st;
uint32_t timestamp;
int rv = 0;
- int h;
+ csrc = buf[0] & 0x0f;
ext = buf[0] & 0x10;
payload_type = buf[1] & 0x7f;
if (buf[1] & 0x80)
@@ -610,14 +610,15 @@ static int rtp_parse_packet_internal(RTPDemuxContext *s, AVPacket *pkt,
len -= padding;
}
- h = buf[0] & 0x0F;
- buf += 4*h;
- len -= 4*h;
-
s->seq = seq;
len -= 12;
buf += 12;
+ len -= 4 * csrc;
+ buf += 4 * csrc;
+ if (len < 0)
+ return AVERROR_INVALIDDATA;
+
/* RFC 3550 Section 5.3.1 RTP Header Extension handling */
if (ext) {
if (len < 4)
@@ -638,10 +639,8 @@ static int rtp_parse_packet_internal(RTPDemuxContext *s, AVPacket *pkt,
s->st, pkt, &timestamp, buf, len, seq,
flags);
} else if (st) {
- /* At this point, the RTP header has been stripped;
- * This is ASSUMING that there is only 1 CSRC, which isn't wise. */
- if (av_new_packet(pkt, len) < 0)
- return AVERROR(ENOMEM);
+ if ((rv = av_new_packet(pkt, len)) < 0)
+ return rv;
memcpy(pkt->data, buf, len);
pkt->stream_index = st->index;
} else {