diff mbox

[FFmpeg-devel,1/2] avcodec/diracdec: Check dimensions which are closer to what is allocated in alloc_sequence_buffers()

Message ID 20170719004430.6747-1-michael@niedermayer.cc
State Accepted
Commit edc88646ee407bc342cc94ff495aadafcd377cee
Headers show

Commit Message

Michael Niedermayer July 19, 2017, 12:44 a.m. UTC
Fixes OOM
Fixes: 2674/clusterfuzz-testcase-minimized-4999700518273024

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/diracdec.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Michael Niedermayer July 21, 2017, 2:20 p.m. UTC | #1
On Wed, Jul 19, 2017 at 02:44:29AM +0200, Michael Niedermayer wrote:
> Fixes OOM
> Fixes: 2674/clusterfuzz-testcase-minimized-4999700518273024
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/diracdec.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)

applied

[...]
diff mbox

Patch

diff --git a/libavcodec/diracdec.c b/libavcodec/diracdec.c
index c031b40b5e..71d0ff41b2 100644
--- a/libavcodec/diracdec.c
+++ b/libavcodec/diracdec.c
@@ -2090,7 +2090,10 @@  static int dirac_decode_data_unit(AVCodecContext *avctx, const uint8_t *buf, int
             return ret;
         }
 
-        ret = ff_set_dimensions(avctx, dsh->width, dsh->height);
+        if (CALC_PADDING((int64_t)dsh->width, MAX_DWT_LEVELS) * CALC_PADDING((int64_t)dsh->height, MAX_DWT_LEVELS) > avctx->max_pixels)
+            ret = AVERROR(ERANGE);
+        if (ret >= 0)
+            ret = ff_set_dimensions(avctx, dsh->width, dsh->height);
         if (ret < 0) {
             av_freep(&dsh);
             return ret;