]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/decode/ff_get_buffer: Check for overflow in FFALIGN()
authorMichael Niedermayer <michael@niedermayer.cc>
Tue, 13 Oct 2020 21:01:38 +0000 (23:01 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Tue, 20 Oct 2020 13:33:13 +0000 (15:33 +0200)
Fixes: signed integer overflow: 2147483647 + 64 cannot be represented in type 'int'
Fixes: 26218/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CRI_fuzzer-5734075396259840
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/decode.c

index 257abc7de45e32cde13ae4c82191a3b5f4ab3f21..5a1849f9448f4872390927e896fa4f530797e75a 100644 (file)
@@ -1883,7 +1883,8 @@ int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
     int ret;
 
     if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) {
-        if ((ret = av_image_check_size2(FFALIGN(avctx->width, STRIDE_ALIGN), avctx->height, avctx->max_pixels, AV_PIX_FMT_NONE, 0, avctx)) < 0 || avctx->pix_fmt<0) {
+        if ((unsigned)avctx->width > INT_MAX - STRIDE_ALIGN ||
+            (ret = av_image_check_size2(FFALIGN(avctx->width, STRIDE_ALIGN), avctx->height, avctx->max_pixels, AV_PIX_FMT_NONE, 0, avctx)) < 0 || avctx->pix_fmt<0) {
             av_log(avctx, AV_LOG_ERROR, "video_get_buffer: image parameters invalid\n");
             ret = AVERROR(EINVAL);
             goto fail;