diff mbox series

[FFmpeg-devel,4/4] avformat/mvi: Check count for overflow

Message ID 20201019155955.27725-4-michael@niedermayer.cc
State Accepted
Commit a413ed98632127342ad04b26e0ba0dc26adb70c9
Headers show
Series [FFmpeg-devel,1/4] avformat/genh: Check block_align | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Michael Niedermayer Oct. 19, 2020, 3:59 p.m. UTC
Fixes: left shift of 21378748 by 10 places cannot be represented in type 'int'
Fixes: 26449/clusterfuzz-testcase-minimized-ffmpeg_dem_MVI_fuzzer-5680463374712832

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavformat/mvi.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Michael Niedermayer Oct. 24, 2020, 5:10 p.m. UTC | #1
On Mon, Oct 19, 2020 at 05:59:55PM +0200, Michael Niedermayer wrote:
> Fixes: left shift of 21378748 by 10 places cannot be represented in type 'int'
> Fixes: 26449/clusterfuzz-testcase-minimized-ffmpeg_dem_MVI_fuzzer-5680463374712832
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavformat/mvi.c | 2 ++
>  1 file changed, 2 insertions(+)

will apply

[...]
diff mbox series

Patch

diff --git a/libavformat/mvi.c b/libavformat/mvi.c
index ff5c08bf51..06c9cfe3f0 100644
--- a/libavformat/mvi.c
+++ b/libavformat/mvi.c
@@ -123,6 +123,8 @@  static int read_packet(AVFormatContext *s, AVPacket *pkt)
         count = (mvi->audio_size_counter + mvi->audio_frame_size + 512) >> MVI_FRAC_BITS;
         if (count > mvi->audio_size_left)
             count = mvi->audio_size_left;
+        if ((int64_t)count << MVI_FRAC_BITS > INT_MAX)
+            return AVERROR_INVALIDDATA;
         if ((ret = av_get_packet(pb, pkt, count)) < 0)
             return ret;
         pkt->stream_index = MVI_AUDIO_STREAM_INDEX;