]> git.sesse.net Git - ffmpeg/commitdiff
lavc/pngdec: improve chunk length check
authorAnton Khirnov <anton@khirnov.net>
Fri, 2 Apr 2021 14:00:23 +0000 (16:00 +0200)
committerAnton Khirnov <anton@khirnov.net>
Thu, 8 Apr 2021 09:03:15 +0000 (11:03 +0200)
The length does not cover the chunk type or CRC.

libavcodec/pngdec.c

index f3295688c69c0c1f0c2593ddba1446beacae46e6..0ff81d740c14b0cb5848a9951d12a48281f971a1 100644 (file)
@@ -1217,7 +1217,7 @@ static int decode_frame_common(AVCodecContext *avctx, PNGDecContext *s,
         }
 
         length = bytestream2_get_be32(&s->gb);
-        if (length > 0x7fffffff || length > bytestream2_get_bytes_left(&s->gb)) {
+        if (length > 0x7fffffff || length + 8 > bytestream2_get_bytes_left(&s->gb)) {
             av_log(avctx, AV_LOG_ERROR, "chunk too big\n");
             ret = AVERROR_INVALIDDATA;
             goto fail;