aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2019-04-16 00:41:54 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2019-05-09 11:23:13 +0200
commit485546eec10a13cbacd17901f02794952d621f20 (patch)
tree44953cd714e4f54dc3c3f15b728d4044c6e2cef9
parent3adb15617d5db5fb9b57c64ea0c6a91c57587a0a (diff)
downloadffmpeg-485546eec10a13cbacd17901f02794952d621f20.tar.gz
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 06ef186fa1b7329c6fe6723372a72464c998059b) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/jpeg2000.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/libavcodec/jpeg2000.c b/libavcodec/jpeg2000.c
index afeb9df27c..afffaa7203 100644
--- a/libavcodec/jpeg2000.c
+++ b/libavcodec/jpeg2000.c
@@ -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?