]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/ralf: Check num_blocks before use
authorMichael Niedermayer <michael@niedermayer.cc>
Mon, 11 May 2020 20:17:43 +0000 (22:17 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Tue, 12 May 2020 19:39:13 +0000 (21:39 +0200)
Fixes: out of array access
Fixes: 20659/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RALF_fuzzer-5739471895265280
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/ralf.c

index 08e8043e30b683efbd1090e808a646362906461f..0080b2394199514f3a07402298819bbc69fdffeb 100644 (file)
@@ -482,6 +482,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr,
     init_get_bits(&gb, src + 2, table_size);
     ctx->num_blocks = 0;
     while (get_bits_left(&gb) > 0) {
+        if (ctx->num_blocks >= FF_ARRAY_ELEMS(ctx->block_size))
+            return AVERROR_INVALIDDATA;
         ctx->block_size[ctx->num_blocks] = get_bits(&gb, 13 + avctx->channels);
         if (get_bits1(&gb)) {
             ctx->block_pts[ctx->num_blocks] = get_bits(&gb, 9);