diff mbox series

[FFmpeg-devel,5/5] avcodec/pnm_parser: Check image size addition for overflow

Message ID 20210330113129.14852-5-michael@niedermayer.cc
State Accepted
Commit 79ac8d55468adc9cb9a0908e671807a2a789b7d0
Headers show
Series [FFmpeg-devel,1/5] avcodec/h265_metadata_bsf: Check nb_units before accessing the first in h265_metadata_update_fragment()
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Michael Niedermayer March 30, 2021, 11:31 a.m. UTC
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>
---
 libavcodec/pnm_parser.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libavcodec/pnm_parser.c b/libavcodec/pnm_parser.c
index f3be6d640c..a822c17a2e 100644
--- a/libavcodec/pnm_parser.c
+++ b/libavcodec/pnm_parser.c
@@ -111,7 +111,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)