rtpdec: Limit writing to the buffer size
authorMartin Storsjö <martin@martin.st>
Tue, 11 Dec 2012 16:58:59 +0000 (18:58 +0200)
committerMartin Storsjö <martin@martin.st>
Wed, 12 Dec 2012 10:18:16 +0000 (12:18 +0200)
This fixes potential buffer overwrites.

Signed-off-by: Martin Storsjö <martin@martin.st>
libavformat/rtpdec.c

index 3b03bda..b83a79b 100644 (file)
@@ -531,7 +531,7 @@ static int rtp_parse_packet_internal(RTPDemuxContext *s, AVPacket *pkt,
         if (ret < 0)
             return AVERROR(EAGAIN);
         if (ret < len) {
         if (ret < 0)
             return AVERROR(EAGAIN);
         if (ret < len) {
-            s->read_buf_size = len - ret;
+            s->read_buf_size = FFMIN(len - ret, sizeof(s->buf));
             memcpy(s->buf, buf + ret, s->read_buf_size);
             s->read_buf_index = 0;
             return 1;
             memcpy(s->buf, buf + ret, s->read_buf_size);
             s->read_buf_index = 0;
             return 1;