1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-28 20:53:54 +02:00

avcodec/pnm_parser: Check image size addition for overflow

Fixes: assertion failure
Fixes: out of array access
Fixes: 32664/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PGMYUV_fuzzer-6533642202513408.fuzz
Fixes: 32669/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PGMYUV_fuzzer-6001928875147264

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 79ac8d5546)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer 2021-03-30 13:22:14 +02:00
parent dae4efc282
commit 0b2d4997ba

View File

@ -67,7 +67,7 @@ retry:
} else {
int ret = avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height);
next = pnmctx.bytestream - pnmctx.bytestream_start;
if (ret >= 0)
if (ret >= 0 && next + (uint64_t)ret <= INT_MAX)
next += ret;
if (pnmctx.bytestream_start != buf)
next -= pc->index;