1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-01-08 13:22:53 +02:00

avcodec/jpeg2000: Check stepsize before using it

Fixes: value 1.87633e+10 is outside the range of representable values of type 'int'
Fixes: Undefined behavior
Fixes: 14246/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_fuzzer-5758393601490944

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 06ef186fa1)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer 2019-04-16 00:41:54 +02:00
parent 85b8a4d2c7
commit b131d7653e

View File

@ -247,6 +247,11 @@ static void init_band_stepsize(AVCodecContext *avctx,
}
}
if (band->f_stepsize > (INT_MAX >> 15)) {
band->f_stepsize = 0;
av_log(avctx, AV_LOG_ERROR, "stepsize out of range\n");
}
band->i_stepsize = band->f_stepsize * (1 << 15);
/* FIXME: In OpenJPEG code stepsize = stepsize * 0.5. Why?