aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2019-10-25 01:12:15 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2019-11-15 12:25:47 +0100
commit07f16ceb8e71c7ae07f45d7a560c20e5ab460d96 (patch)
treef7974158b2613c6b5a94ae0811cd709c76903121
parentd737429008ee2a4362c878bf44dfe966bc545698 (diff)
downloadffmpeg-07f16ceb8e71c7ae07f45d7a560c20e5ab460d96.tar.gz
avcodec/cook: Move up and extend block_align check
Fixes: signed integer overflow: 2046820356 * 8 cannot be represented in type 'int' Fixes: 18391/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_COOK_fuzzer-5631674666188800 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 1c63edcdd208bf18a3be66e94deb6ac115f6364e) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/cook.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/libavcodec/cook.c b/libavcodec/cook.c
index 6fabed9ed7..dbf55c8226 100644
--- a/libavcodec/cook.c
+++ b/libavcodec/cook.c
@@ -1075,6 +1075,9 @@ static av_cold int cook_decode_init(AVCodecContext *avctx)
return AVERROR_INVALIDDATA;
}
+ if (avctx->block_align >= INT_MAX / 8)
+ return AVERROR(EINVAL);
+
/* Initialize RNG. */
av_lfg_init(&q->random_state, 0);
@@ -1234,10 +1237,6 @@ static av_cold int cook_decode_init(AVCodecContext *avctx)
if ((ret = init_cook_vlc_tables(q)))
return ret;
-
- if (avctx->block_align >= UINT_MAX / 2)
- return AVERROR(EINVAL);
-
/* Pad the databuffer with:
DECODE_BYTES_PAD1 or DECODE_BYTES_PAD2 for decode_bytes(),
AV_INPUT_BUFFER_PADDING_SIZE, for the bitstreamreader. */