aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2023-04-16 15:06:59 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2023-06-04 20:24:48 +0200
commit30cdacf8c2ff111a362671be7cec7e4f4000b469 (patch)
tree9fa9c323f9c681fb6adff380ad709f8caf14d2ff
parentb79b50a3082a602277fc3e006d581b22d08cce18 (diff)
downloadffmpeg-30cdacf8c2ff111a362671be7cec7e4f4000b469.tar.gz
avcodec/pngdec: Do not pass AVFrame into global header decode
The global header should not contain a frame, and decoding it would result in leaks Fixes: memleak Fixes: 45982/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APNG_fuzzer-6603443149340672 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit d31d4f32283f765c79d6e127d31ee2c37a0acef7) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/pngdec.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
index ce570e3d55..88ebd82f78 100644
--- a/libavcodec/pngdec.c
+++ b/libavcodec/pngdec.c
@@ -620,6 +620,8 @@ static int decode_idat_chunk(AVCodecContext *avctx, PNGDecContext *s,
int ret;
size_t byte_depth = s->bit_depth > 8 ? 2 : 1;
+ if (!p)
+ return AVERROR_INVALIDDATA;
if (!(s->hdr_state & PNG_IHDR)) {
av_log(avctx, AV_LOG_ERROR, "IDAT without IHDR\n");
return AVERROR_INVALIDDATA;
@@ -1292,6 +1294,8 @@ static int decode_frame_common(AVCodecContext *avctx, PNGDecContext *s,
break;
}
case MKTAG('i', 'C', 'C', 'P'): {
+ if (!p)
+ return AVERROR_INVALIDDATA;
if ((ret = decode_iccp_chunk(s, length, p)) < 0)
goto fail;
break;
@@ -1314,6 +1318,9 @@ skip_tag:
}
exit_loop:
+ if (!p)
+ return AVERROR_INVALIDDATA;
+
if (avctx->codec_id == AV_CODEC_ID_PNG &&
avctx->skip_frame == AVDISCARD_ALL) {
return 0;
@@ -1460,7 +1467,7 @@ static int decode_frame_apng(AVCodecContext *avctx,
s->zstream.zfree = ff_png_zfree;
bytestream2_init(&s->gb, avctx->extradata, avctx->extradata_size);
- if ((ret = decode_frame_common(avctx, s, p, avpkt)) < 0)
+ if ((ret = decode_frame_common(avctx, s, NULL, avpkt)) < 0)
goto end;
}