]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/arbc: Check nb_tiles against dimensions
authorMichael Niedermayer <michael@niedermayer.cc>
Sun, 17 Feb 2019 21:40:34 +0000 (22:40 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Mon, 25 Feb 2019 17:03:24 +0000 (18:03 +0100)
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

index 4558304f1203b2c6968326e7a4b7ad36e3f4bffd..841a9f10acce3aa53e3f398b55fed3aba6528171 100644 (file)
@@ -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);