diff mbox

[FFmpeg-devel] avcodec/diracdec: Correct max pixels check

Message ID 20190225213511.4497-1-michael@niedermayer.cc
State Accepted
Commit 1eb35eb50ed32c9f36b6f3e39e8058d13f693c5e
Headers show

Commit Message

Michael Niedermayer Feb. 25, 2019, 9:35 p.m. UTC
Dirac internally allocates 5 images per plane and frame currently. One being the actual
image the other 4 being filtered for motion compensation.

Fixes: Out of memory
Fixes: 12870/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DIRAC_fuzzer-5684825871089664

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 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Michael Niedermayer March 3, 2019, 11:05 a.m. UTC | #1
On Mon, Feb 25, 2019 at 10:35:11PM +0100, Michael Niedermayer wrote:
> Dirac internally allocates 5 images per plane and frame currently. One being the actual
> image the other 4 being filtered for motion compensation.
> 
> Fixes: Out of memory
> Fixes: 12870/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DIRAC_fuzzer-5684825871089664
> 
> 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 | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

will apply

[...]
diff mbox

Patch

diff --git a/libavcodec/diracdec.c b/libavcodec/diracdec.c
index db010b49cf..30b4bfad79 100644
--- a/libavcodec/diracdec.c
+++ b/libavcodec/diracdec.c
@@ -2137,7 +2137,7 @@  static int dirac_decode_data_unit(AVCodecContext *avctx, const uint8_t *buf, int
             return ret;
         }
 
-        if (CALC_PADDING((int64_t)dsh->width, MAX_DWT_LEVELS) * CALC_PADDING((int64_t)dsh->height, MAX_DWT_LEVELS) > avctx->max_pixels)
+        if (CALC_PADDING((int64_t)dsh->width, MAX_DWT_LEVELS) * CALC_PADDING((int64_t)dsh->height, MAX_DWT_LEVELS) * 5LL > avctx->max_pixels)
             ret = AVERROR(ERANGE);
         if (ret >= 0)
             ret = ff_set_dimensions(avctx, dsh->width, dsh->height);