[FFmpeg-cvslog] avcodec/jpeg2000: Check sum of sizes of band->prec before allocating

Michael Niedermayer git at videolan.org
Mon Jan 15 21:00:55 EET 2018


ffmpeg | branch: master | Michael Niedermayer <michael at niedermayer.cc> | Sun Jan 14 00:39:40 2018 +0100| [6887e412434776eb260ad3904f565be491dd5726] | committer: Michael Niedermayer

avcodec/jpeg2000: Check sum of sizes of band->prec before allocating

Fixes: OOM
Fixes: 4810/clusterfuzz-testcase-minimized-6034253235093504

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=6887e412434776eb260ad3904f565be491dd5726
---

 libavcodec/jpeg2000.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavcodec/jpeg2000.c b/libavcodec/jpeg2000.c
index e7f03bd0df..8e90980976 100644
--- a/libavcodec/jpeg2000.c
+++ b/libavcodec/jpeg2000.c
@@ -541,6 +541,9 @@ int ff_jpeg2000_init_component(Jpeg2000Component *comp,
         if (!reslevel->band)
             return AVERROR(ENOMEM);
 
+        if (reslevel->num_precincts_x * (uint64_t)reslevel->num_precincts_y * reslevel->nbands > avctx->max_pixels / sizeof(*reslevel->band->prec))
+            return AVERROR(ENOMEM);
+
         for (bandno = 0; bandno < reslevel->nbands; bandno++, gbandno++) {
             ret = init_band(avctx, reslevel,
                             comp, codsty, qntsty,



More information about the ffmpeg-cvslog mailing list