]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/rpza: Check that there is enough data for all the blocks
authorMichael Niedermayer <michael@niedermayer.cc>
Sun, 16 Dec 2018 18:13:27 +0000 (19:13 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Wed, 19 Dec 2018 19:09:03 +0000 (20:09 +0100)
Fixes: Timeout
Fixes: 11547/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RPZA_fuzzer-5678435842654208
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/rpza.c

index cffbfe441652c0a0fe517ddd39371146a2522cec..8e1efa24450ef6debee826ee2d65a7c7f8540a35 100644 (file)
@@ -105,6 +105,9 @@ static int rpza_decode_stream(RpzaContext *s)
     /* Number of 4x4 blocks in frame. */
     total_blocks = ((s->avctx->width + 3) / 4) * ((s->avctx->height + 3) / 4);
 
+    if (total_blocks / 32 > bytestream2_get_bytes_left(&s->gb))
+        return AVERROR_INVALIDDATA;
+
     if ((ret = ff_reget_buffer(s->avctx, s->frame)) < 0)
         return ret;
     pixels = (uint16_t *)s->frame->data[0];