[FFmpeg-cvslog] mjpeg: Detect overreads in mjpeg_decode_scan() and error out.

Michael Niedermayer git at videolan.org
Thu Nov 3 02:57:59 CET 2011


ffmpeg | branch: release/0.5 | Michael Niedermayer <michaelni at gmx.at> | Thu Apr 21 22:03:24 2011 +0200| [eed5697f99927c78956fde6ee6f1ac87f3c6d261] | committer: Reinhard Tartler

mjpeg: Detect overreads in mjpeg_decode_scan() and error out.

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
Signed-off-by: Ronald S. Bultje <rbultje at google.com>
Signed-off-by: Reinhard Tartler <siretart at tauware.de>

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

 libavcodec/mjpegdec.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 145719c..e5c9f38 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -784,6 +784,10 @@ static int mjpeg_decode_scan(MJpegDecodeContext *s, int nb_components, int Ah, i
             if (s->restart_interval && !s->restart_count)
                 s->restart_count = s->restart_interval;
 
+            if(get_bits_count(&s->gb)>s->gb.size_in_bits){
+                av_log(s->avctx, AV_LOG_ERROR, "overread %d\n", get_bits_count(&s->gb) - s->gb.size_in_bits);
+                return -1;
+            }
             for(i=0;i<nb_components;i++) {
                 uint8_t *ptr;
                 int n, h, v, x, y, c, j;



More information about the ffmpeg-cvslog mailing list