aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2020-10-13 23:01:38 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2021-09-09 13:37:21 +0200
commitd2cefe21e1d61e940c11e64233d3ceaf46c40c3c (patch)
tree3dbfc218be23e8702d4fa9120bb32ef677982ffd /libavcodec
parentc8c0ed9e2bf8c26eec22bd2fb8c4daa1cf6f3e2c (diff)
downloadffmpeg-d2cefe21e1d61e940c11e64233d3ceaf46c40c3c.tar.gz
avcodec/decode/ff_get_buffer: Check for overflow in FFALIGN()
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> (cherry picked from commit 939b72b02e40a7db440b68f31ab23bd550785344) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/decode.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index c89c77c43a..9f11feb4c5 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1864,7 +1864,8 @@ static int get_buffer_internal(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");
return AVERROR(EINVAL);
}