rtpproto: Check the size before reading buf[1]
authorMartin Storsjö <martin@martin.st>
Wed, 31 Jul 2013 09:45:33 +0000 (12:45 +0300)
committerMartin Storsjö <martin@martin.st>
Thu, 1 Aug 2013 06:41:21 +0000 (09:41 +0300)
I doubt that anyone ever would try to send a 1 byte packet
via the RTP protocol, but check just in case - it shouldn't
crash at least.

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

index 4e177b9..b21c121 100644 (file)
@@ -368,6 +368,9 @@ static int rtp_write(URLContext *h, const uint8_t *buf, int size)
     int ret;
     URLContext *hd;
 
+    if (size < 2)
+        return AVERROR(EINVAL);
+
     if (RTP_PT_IS_RTCP(buf[1])) {
         /* RTCP payload type */
         hd = s->rtcp_hd;