[FFmpeg-cvslog] avcodec/pnm_parser: Check av_image_get_buffer_size() for failure
Michael Niedermayer
git at videolan.org
Sat Feb 20 22:11:01 EET 2021
ffmpeg | branch: release/4.3 | Michael Niedermayer <michael at niedermayer.cc> | Wed Feb 10 22:28:20 2021 +0100| [12b329a51d1ab36e06d5cb42527a52b62eb52b06] | committer: Michael Niedermayer
avcodec/pnm_parser: Check av_image_get_buffer_size() for failure
Fixes: out of array access
Fixes: 30135/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PBM_fuzzer-4997145650397184
Fixes: 30208/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PGMYUV_fuzzer-5605891665690624.fuzz
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Paul B Mahol <onemda at gmail.com>
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
(cherry picked from commit 5314a4996cc76e2a8534c74a66f5181e95ac64fc)
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=12b329a51d1ab36e06d5cb42527a52b62eb52b06
---
libavcodec/pnm_parser.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/libavcodec/pnm_parser.c b/libavcodec/pnm_parser.c
index d19dbfe98c..f3be6d640c 100644
--- a/libavcodec/pnm_parser.c
+++ b/libavcodec/pnm_parser.c
@@ -109,8 +109,10 @@ retry:
if (next == END_NOT_FOUND)
pnmpc->ascii_scan = sync - pnmctx.bytestream + skip;
} else {
- next = pnmctx.bytestream - pnmctx.bytestream_start + skip
- + av_image_get_buffer_size(avctx->pix_fmt, avctx->width, avctx->height, 1);
+ 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)
+ next += ret;
}
if (next != END_NOT_FOUND && pnmctx.bytestream_start != buf + skip)
next -= pc->index;
More information about the ffmpeg-cvslog
mailing list