Skip to content

Commit c64180f

Browse files
committed
lavc/pngdec: improve chunk length check
The length does not cover the chunk type or CRC. (cherry picked from commit ae08eec) Signed-off-by: Anton Khirnov <anton@khirnov.net>
1 parent 8ee432d commit c64180f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

libavcodec/pngdec.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1217,7 +1217,7 @@ static int decode_frame_common(AVCodecContext *avctx, PNGDecContext *s,
12171217
}
12181218

12191219
length = bytestream2_get_be32(&s->gb);
1220-
if (length > 0x7fffffff || length > bytestream2_get_bytes_left(&s->gb)) {
1220+
if (length > 0x7fffffff || length + 8 > bytestream2_get_bytes_left(&s->gb)) {
12211221
av_log(avctx, AV_LOG_ERROR, "chunk too big\n");
12221222
ret = AVERROR_INVALIDDATA;
12231223
goto fail;

0 commit comments

Comments
 (0)