]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/cdtoons: Fix off by 4 check on diff_size
authorMichael Niedermayer <michael@niedermayer.cc>
Thu, 20 Feb 2020 17:51:36 +0000 (18:51 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Fri, 21 Feb 2020 20:42:11 +0000 (21:42 +0100)
Fixes: out of array read
Fixes: 20742/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CDTOONS_fuzzer-5738148607033344
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 dc4fa6bf0bafcb731e5efc7e1342c8132215f4ec..d5dce6351fbc4c9db817317d62b3113964f576ec 100644 (file)
@@ -269,7 +269,7 @@ static int cdtoons_decode_frame(AVCodecContext *avctx, void *data,
                 diff_size  = bytestream_get_be32(&buf);
                 width      = bytestream_get_be16(&buf);
                 height     = bytestream_get_be16(&buf);
-                if (diff_size < 4 || diff_size - 4 > eod - buf) {
+                if (diff_size < 8 || diff_size - 4 > eod - buf) {
                     av_log(avctx, AV_LOG_WARNING, "Ran (seriously) out of data for Diff frame data.\n");
                     return AVERROR_INVALIDDATA;
                 }