[FFmpeg-devel,2/4] avcodec/jpeg2000: Check stepsize before using it

Submitted by Michael Niedermayer on April 16, 2019, 2:48 p.m.

Details

Message ID 20190416144834.20300-2-michael@niedermayer.cc
State Accepted
Commit 06ef186fa1b7329c6fe6723372a72464c998059b
Headers show

Commit Message

Michael Niedermayer April 16, 2019, 2:48 p.m.
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>
---
 libavcodec/jpeg2000.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Michael Niedermayer April 25, 2019, 9:42 a.m.
On Tue, Apr 16, 2019 at 04:48:32PM +0200, Michael Niedermayer wrote:
> 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>
> ---
>  libavcodec/jpeg2000.c | 5 +++++
>  1 file changed, 5 insertions(+)

will apply jpeg2000 patchset


[...]

Patch hide | download patch | download mbox

diff --git a/libavcodec/jpeg2000.c b/libavcodec/jpeg2000.c
index 8e90980976..3f50bf9fb3 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?