avformat/rtpenc_jpeg: Check remaining buffer size for SOS
authorMichael Niedermayer <michaelni@gmx.at>
Tue, 12 May 2015 15:55:40 +0000 (17:55 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 10 Jun 2015 00:13:11 +0000 (02:13 +0200)
Fixes CID1238818

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 81198a68370e88f7d02f16de58db36713c2a50b6)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavformat/rtpenc_jpeg.c

index 7eb0e23..47898a3 100644 (file)
@@ -80,6 +80,11 @@ void ff_rtp_send_jpeg(AVFormatContext *s1, const uint8_t *buf, int size)
         } else if (buf[i + 1] == SOS) {
             /* SOS is last marker in the header */
             i += AV_RB16(&buf[i + 2]) + 2;
+            if (i > size) {
+                av_log(s1, AV_LOG_ERROR,
+                       "Insufficient data. Aborted!\n");
+                return;
+            }
             break;
         }
     }