aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2021-02-22 20:20:48 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2021-09-09 13:53:29 +0200
commit7560bd30bad9529e89f9bfd8308039bbee2c9edd (patch)
tree5642fb7b74aad8618a13ddca1b11f9416759bb09
parent161717ee5aaec312d683f1cc9832b510135f16b9 (diff)
downloadffmpeg-7560bd30bad9529e89f9bfd8308039bbee2c9edd.tar.gz
avformat/mvi: Check audio size for more overflows
Fixes: left shift of negative value -352256000 Fixes: 30837/clusterfuzz-testcase-minimized-ffmpeg_dem_MVI_fuzzer-5755626262888448 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 403b35e16e16a8c4a13e531ccdc23598f685ca20) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavformat/mvi.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/libavformat/mvi.c b/libavformat/mvi.c
index 0b53473671..6aad6cb86a 100644
--- a/libavformat/mvi.c
+++ b/libavformat/mvi.c
@@ -119,6 +119,10 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
mvi->video_frame_size = (mvi->get_int)(pb);
if (mvi->audio_size_left == 0)
return AVERROR(EIO);
+ if (mvi->audio_size_counter + 512 > UINT64_MAX - mvi->audio_frame_size ||
+ mvi->audio_size_counter + 512 + mvi->audio_frame_size >= ((uint64_t)INT32_MAX) << MVI_FRAC_BITS)
+ return AVERROR_INVALIDDATA;
+
count = (mvi->audio_size_counter + mvi->audio_frame_size + 512) >> MVI_FRAC_BITS;
if (count > mvi->audio_size_left)
count = mvi->audio_size_left;