]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/cdtoons: Check sprite_offset is within the packet
authorMichael Niedermayer <michael@niedermayer.cc>
Mon, 11 May 2020 19:08:17 +0000 (21:08 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Tue, 12 May 2020 19:39:13 +0000 (21:39 +0200)
Fixes: out of array read
Fixes: 20659/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CDTOONS_fuzzer-5754518731227136
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/cdtoons.c

index 13f9a60f0f8c68b82e64163c6b68ceaeb247a0af..a8609815c123348c7283019e0d8a532184b54e41 100644 (file)
@@ -190,6 +190,9 @@ static int cdtoons_decode_frame(AVCodecContext *avctx, void *data,
     palette_set        = bytestream_get_byte(&buf);
     buf               += 5;
 
+    if (sprite_offset > buf_size)
+        return AVERROR_INVALIDDATA;
+
     /* read new sprites introduced in this frame */
     buf = avpkt->data + sprite_offset;
     while (sprite_count--) {