diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2021-03-30 14:22:14 +0300 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2021-09-10 17:04:26 +0300 |
commit | d1ec3974a4d81a9631ca1ed60a4078ded3e2f195 (patch) | |
tree | b7430e291886afe1566e422ca9e41bcd06a70849 /libavcodec | |
parent | 746fda9419ec4b073c23b08de50686c9be81de41 (diff) |
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')
-rw-r--r-- | libavcodec/pnm_parser.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/libavcodec/pnm_parser.c b/libavcodec/pnm_parser.c index 29183f8f31..10a215f3c6 100644 --- a/libavcodec/pnm_parser.c +++ b/libavcodec/pnm_parser.c @@ -108,7 +108,7 @@ retry: } else { int ret = av_image_get_buffer_size(avctx->pix_fmt, avctx->width, avctx->height, 1); next = pnmctx.bytestream - pnmctx.bytestream_start + skip; - if (ret >= 0) + if (ret >= 0 && next + (uint64_t)ret <= INT_MAX) next += ret; } if (next != END_NOT_FOUND && pnmctx.bytestream_start != buf + skip) |