Browse code

avcodec/jpeg2000: Check comp coords to be within the supported size

Fixes assertion failure
Fixes: 03e0abe721b1174856d41a1eb5d6a896/signal_sigabrt_7ffff6ae7cc9_3813_e71bf3541abed3ccba031cd5ba0269a4.avi

This fix is choosen to be simple to backport, better solution
for master is planed

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit a1a8cbcb35ef2759a66b4f0875785e4b3f277057)
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>

Michael Niedermayer authored on 2015/11/16 04:49:17
Showing 1 changed files
... ...
@@ -213,6 +213,11 @@ int ff_jpeg2000_init_component(Jpeg2000Component *comp,
213 213
     // component size comp->coord is uint16_t so ir cannot overflow
214 214
     csize = (comp->coord[0][1] - comp->coord[0][0]) *
215 215
             (comp->coord[1][1] - comp->coord[1][0]);
216
+    if (comp->coord[0][1] > 32768 ||
217
+        comp->coord[1][1] > 32768) {
218
+        av_log(avctx, AV_LOG_ERROR, "component size too large\n");
219
+        return AVERROR_PATCHWELCOME;
220
+    }
216 221
 
217 222
     if (codsty->transform == FF_DWT97) {
218 223
         csize += AV_INPUT_BUFFER_PADDING_SIZE / sizeof(*comp->f_data);