diff mbox

[FFmpeg-devel] avcodec/ivi: Move buffer/block end check to caller of ivi_dc_transform()

Message ID 20190411225827.31828-1-michael@niedermayer.cc
State Accepted
Commit 110dce96331529a13cc815d3c852aed9d37f83d0
Headers show

Commit Message

Michael Niedermayer April 11, 2019, 10:58 p.m. UTC
Fixes: assertion failure
Fixes: 14078/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_INDEO5_fuzzer-5760571284127744

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

Comments

Michael Niedermayer April 19, 2019, 6:12 p.m. UTC | #1
On Fri, Apr 12, 2019 at 12:58:27AM +0200, Michael Niedermayer wrote:
> Fixes: assertion failure
> Fixes: 14078/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_INDEO5_fuzzer-5760571284127744
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/ivi.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)

will apply

[...]
diff mbox

Patch

diff --git a/libavcodec/ivi.c b/libavcodec/ivi.c
index 0f77873a83..e9c4b9b831 100644
--- a/libavcodec/ivi.c
+++ b/libavcodec/ivi.c
@@ -496,12 +496,6 @@  static int ivi_dec_tile_data_size(GetBitContext *gb)
 static int ivi_dc_transform(const IVIBandDesc *band, int *prev_dc, int buf_offs,
                             int blk_size)
 {
-    int buf_size = band->pitch * band->aheight - buf_offs;
-    int min_size = (blk_size - 1) * band->pitch + blk_size;
-
-    if (min_size > buf_size)
-        return AVERROR_INVALIDDATA;
-
     band->dc_transform(prev_dc, band->buf + buf_offs,
                        band->pitch, blk_size);
 
@@ -732,6 +726,11 @@  static int ivi_decode_blocks(GetBitContext *gb, const IVIBandDesc *band,
                 if (ret < 0)
                     return ret;
             } else {
+                int buf_size = band->pitch * band->aheight - buf_offs;
+                int min_size = (blk_size - 1) * band->pitch + blk_size;
+
+                if (min_size > buf_size)
+                    return AVERROR_INVALIDDATA;
                 /* block not coded */
                 /* for intra blocks apply the dc slant transform */
                 /* for inter - perform the motion compensation without delta */