aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/pnm_parser.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2021-03-30 13:22:14 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2021-10-09 22:02:20 +0200
commit57685d44eeee3b11f9915de396d1da4766f46186 (patch)
tree3b5d1dab832884285cd510e874d78cc71244f664 /libavcodec/pnm_parser.c
parent1ac69695172dd844352ed7f54cc05cd8bea32492 (diff)
downloadffmpeg-57685d44eeee3b11f9915de396d1da4766f46186.tar.gz
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 79ac8d55468adc9cb9a0908e671807a2a789b7d0) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/pnm_parser.c')
-rw-r--r--libavcodec/pnm_parser.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/libavcodec/pnm_parser.c b/libavcodec/pnm_parser.c
index f7d6f85f2f..2036cefba8 100644
--- a/libavcodec/pnm_parser.c
+++ b/libavcodec/pnm_parser.c
@@ -71,7 +71,7 @@ retry:
} else {
int ret = av_image_get_buffer_size(avctx->pix_fmt, avctx->width, avctx->height, 1);
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;