diff mbox

[FFmpeg-devel,2/2] avcodec/arbc: Check nb_tiles against dimensions

Message ID 20190218000756.29768-2-michael@niedermayer.cc
State Accepted
Commit 160851bceed719c45459c64ab62b8e5bc130e2ee
Headers show

Commit Message

Michael Niedermayer Feb. 18, 2019, 12:07 a.m. UTC
Fixes: Timeout
Fixes: 12967/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ARBC_fuzzer-5639021454163968

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

Comments

Michael Niedermayer Feb. 25, 2019, 4:14 p.m. UTC | #1
On Mon, Feb 18, 2019 at 01:07:56AM +0100, Michael Niedermayer wrote:
> Fixes: Timeout
> Fixes: 12967/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ARBC_fuzzer-5639021454163968
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/arbc.c | 6 ++++++
>  1 file changed, 6 insertions(+)

will apply

[...]
diff mbox

Patch

diff --git a/libavcodec/arbc.c b/libavcodec/arbc.c
index 4558304f12..841a9f10ac 100644
--- a/libavcodec/arbc.c
+++ b/libavcodec/arbc.c
@@ -45,6 +45,9 @@  static void fill_tile4(AVCodecContext *avctx, uint8_t *color, AVFrame *frame)
     int nb_tiles = bytestream2_get_le16(gb);
     int h = avctx->height - 1;
 
+    if ((avctx->width / 4 + 1) * (avctx->height / 4 + 1) < nb_tiles)
+        return;
+
     for (int i = 0; i < nb_tiles; i++) {
         int y = bytestream2_get_byte(gb);
         int x = bytestream2_get_byte(gb);
@@ -79,6 +82,9 @@  static void fill_tileX(AVCodecContext *avctx, int tile_width, int tile_height,
     int nb_tiles = bytestream2_get_le16(gb);
     int h = avctx->height - 1;
 
+    if ((avctx->width / tile_width + 1) * (avctx->height / tile_height + 1) < nb_tiles)
+        return;
+
     for (int i = 0; i < nb_tiles; i++) {
         int y = bytestream2_get_byte(gb);
         int x = bytestream2_get_byte(gb);