[FFmpeg-cvslog] jpeg2000: check len before parsing header

Michael Niedermayer git at videolan.org
Wed Jul 3 14:45:42 CEST 2013


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Mon Jul  1 10:01:08 2013 +0200| [fd54dd028bc9f7bfb80ebf823a533dc84b73f936] | committer: Luca Barbato

jpeg2000: check len before parsing header

Avoid overread.

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
Signed-off-by: Luca Barbato <lu_zero at gentoo.org>

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

 libavcodec/jpeg2000dec.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 8cc1094..e1da04d 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -1241,9 +1241,10 @@ static int jpeg2000_read_main_headers(Jpeg2000DecoderContext *s)
         if (marker == JPEG2000_EOC)
             break;
 
-        if (bytestream2_get_bytes_left(&s->g) < 2)
-            return AVERROR_INVALIDDATA;
         len = bytestream2_get_be16u(&s->g);
+        if (len < 2 || bytestream2_get_bytes_left(&s->g) < len - 2)
+            return AVERROR_INVALIDDATA;
+
         switch (marker) {
         case JPEG2000_SIZ:
             ret = get_siz(s);



More information about the ffmpeg-cvslog mailing list