mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-24 13:56:33 +02:00
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>
This commit is contained in:
parent
344f333c6c
commit
9000efe97f
@ -647,6 +647,8 @@ static int decode_idat_chunk(AVCodecContext *avctx, PNGDecContext *s,
|
|||||||
int ret;
|
int ret;
|
||||||
size_t byte_depth = s->bit_depth > 8 ? 2 : 1;
|
size_t byte_depth = s->bit_depth > 8 ? 2 : 1;
|
||||||
|
|
||||||
|
if (!p)
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
if (!(s->hdr_state & PNG_IHDR)) {
|
if (!(s->hdr_state & PNG_IHDR)) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "IDAT without IHDR\n");
|
av_log(avctx, AV_LOG_ERROR, "IDAT without IHDR\n");
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
@ -1383,6 +1385,9 @@ static int decode_frame_common(AVCodecContext *avctx, PNGDecContext *s,
|
|||||||
}
|
}
|
||||||
exit_loop:
|
exit_loop:
|
||||||
|
|
||||||
|
if (!p)
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
if (avctx->codec_id == AV_CODEC_ID_PNG &&
|
if (avctx->codec_id == AV_CODEC_ID_PNG &&
|
||||||
avctx->skip_frame == AVDISCARD_ALL) {
|
avctx->skip_frame == AVDISCARD_ALL) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -1643,7 +1648,7 @@ static int decode_frame_apng(AVCodecContext *avctx, AVFrame *p,
|
|||||||
if ((ret = inflateReset(&s->zstream.zstream)) != Z_OK)
|
if ((ret = inflateReset(&s->zstream.zstream)) != Z_OK)
|
||||||
return AVERROR_EXTERNAL;
|
return AVERROR_EXTERNAL;
|
||||||
bytestream2_init(&s->gb, avctx->extradata, avctx->extradata_size);
|
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)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user