diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2022-09-11 00:11:20 +0200 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2022-11-03 23:29:47 +0100 |
commit | d282d019c27f3d9d3e5b76a6415b1dd29042bb8c (patch) | |
tree | 07a34007b957faab7c451977e83df56b50580824 /libavcodec | |
parent | 4dcc092a5a302349b653ad9eb123443d6a3ed365 (diff) | |
download | ffmpeg-d282d019c27f3d9d3e5b76a6415b1dd29042bb8c.tar.gz |
avcodec/tta: Check 24bit scaling for overflow
Fixes: signed integer overflow: -8427924 * 256 cannot be represented in type 'int'
Fixes: 48798/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TTA_fuzzer-5409428670644224
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 3993345f915bccceee315f44d412445346990e14)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/tta.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/libavcodec/tta.c b/libavcodec/tta.c index 17b4ca9032..109d01ff24 100644 --- a/libavcodec/tta.c +++ b/libavcodec/tta.c @@ -373,8 +373,15 @@ static int tta_decode_frame(AVCodecContext *avctx, void *data, case 3: { // shift samples for 24-bit sample format int32_t *samples = (int32_t *)frame->data[0]; - for (i = 0; i < framelen * s->channels; i++) - *samples++ *= 256; + int overflow = 0; + + for (i = 0; i < framelen * s->channels; i++) { + int scaled = *samples * 256U; + overflow += (scaled >> 8 != *samples); + *samples++ = scaled; + } + if (overflow) + av_log(avctx, AV_LOG_WARNING, "%d overflows occurred on 24bit upscale\n", overflow); // reset decode buffer s->decode_buffer = NULL; break; |