[FFmpeg-cvslog] avcodec/mjpegdec: Check len in ff_mjpeg_decode_dqt()

Michael Niedermayer git at videolan.org
Wed May 13 18:43:42 CEST 2015


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Wed May 13 16:51:20 2015 +0200| [dc35a58149c27a3ae2d47a7a393a77a8987454ac] | committer: Michael Niedermayer

avcodec/mjpegdec: Check len in ff_mjpeg_decode_dqt()

Fixes CID1239060

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=dc35a58149c27a3ae2d47a7a393a77a8987454ac
---

 libavcodec/mjpegdec.c |    5 +++++
 1 file changed, 5 insertions(+)

diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 2d6451c..2e019d9 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -163,6 +163,11 @@ int ff_mjpeg_decode_dqt(MJpegDecodeContext *s)
 
     len = get_bits(&s->gb, 16) - 2;
 
+    if (8*len > get_bits_left(&s->gb)) {
+        av_log(s->avctx, AV_LOG_ERROR, "dqt: len %d is too large\n", len);
+        return AVERROR_INVALIDDATA;
+    }
+
     while (len >= 65) {
         int pr = get_bits(&s->gb, 4);
         if (pr > 1) {



More information about the ffmpeg-cvslog mailing list