mjpeg: abort decoding if packet is too large.
authorRonald S. Bultje <rsbultje@gmail.com>
Thu, 23 Feb 2012 20:22:40 +0000 (12:22 -0800)
committerReinhard Tartler <siretart@tauware.de>
Sun, 26 Feb 2012 09:03:16 +0000 (10:03 +0100)
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
(cherry picked from commit ab492ca2ab105aeb24d955f3f03756bdb3139ee1)

Signed-off-by: Anton Khirnov <anton@khirnov.net>
libavcodec/mjpegdec.c

index 2ae502d..49d334b 100644 (file)
@@ -1466,6 +1466,10 @@ int ff_mjpeg_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
         /* EOF */
         if (start_code < 0) {
             goto the_end;
+        } else if (unescaped_buf_size > (1U<<29)) {
+            av_log(avctx, AV_LOG_ERROR, "MJPEG packet 0x%x too big (0x%x/0x%x), corrupt data?\n",
+                   start_code, unescaped_buf_ptr, buf_size);
+            return AVERROR_INVALIDDATA;
         } else {
             av_log(avctx, AV_LOG_DEBUG, "marker=%x avail_size_in_buf=%td\n",
                    start_code, buf_end - buf_ptr);