[FFmpeg-cvslog] avcodec/jpeg2000dec: Fix division by zero in jp2_find_codestream()

Michael Niedermayer git at videolan.org
Wed Jul 26 18:07:49 EEST 2017


ffmpeg | branch: master | Michael Niedermayer <michael at niedermayer.cc> | Mon Jul 24 16:43:24 2017 +0200| [1b00600319506a9bd81b114d2b374051dc1a29a6] | committer: Michael Niedermayer

avcodec/jpeg2000dec: Fix division by zero in jp2_find_codestream()

Fixes: 2707/clusterfuzz-testcase-minimized-5179636394754048

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

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

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

diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index b67efc76bb..dd9c60feb4 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -2075,6 +2075,11 @@ static int jp2_find_codestream(Jpeg2000DecoderContext *s)
                     hden = bytestream2_get_be16u(&s->g);
                     vexp = bytestream2_get_byteu(&s->g);
                     hexp = bytestream2_get_byteu(&s->g);
+                    if (!vnum || !vden || !hnum || !vden) {
+                        bytestream2_seek(&s->g, atom2_end, SEEK_SET);
+                        av_log(s->avctx, AV_LOG_WARNING, "RES box invalid\n");
+                        continue;
+                    }
                     if (vexp > hexp) {
                         vexp -= hexp;
                         hexp = 0;



More information about the ffmpeg-cvslog mailing list