diff mbox series

[FFmpeg-devel,2/2] avcodec/g2meet: Check tile_width in epic_jb_decode_tile()

Message ID 20200405211045.25351-2-michael@niedermayer.cc
State Accepted
Commit 5501bb28ddfa6441dcbf8ea0a964a13aa33f66fe
Headers show
Series [FFmpeg-devel,1/2] avcodec/hapdec: Check tex_size more strictly and before using it | expand

Checks

Context Check Description
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Michael Niedermayer April 5, 2020, 9:10 p.m. UTC
Fixes: out of array access
Fixes: 21469/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_G2M_fuzzer-5199357982015488

Alternatively the arrays can be made bigger or the index can be clipped.
In case a real file with such huge tiles exist we ask the user to upload it.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/g2meet.c | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox series

Patch

diff --git a/libavcodec/g2meet.c b/libavcodec/g2meet.c
index 731d29a5d4..7ef275c9fe 100644
--- a/libavcodec/g2meet.c
+++ b/libavcodec/g2meet.c
@@ -917,6 +917,11 @@  static int epic_jb_decode_tile(G2MContext *c, int tile_x, int tile_y,
     awidth      = FFALIGN(tile_width,  16);
     aheight     = FFALIGN(tile_height, 16);
 
+    if (tile_width > (1 << FF_ARRAY_ELEMS(c->ec.prev_row_rung))) {
+        avpriv_request_sample(avctx, "large tile width");
+        return AVERROR_INVALIDDATA;
+    }
+
     if (els_dsize) {
         int ret, i, j, k;
         uint8_t tr_r, tr_g, tr_b, *buf;