diff mbox

[FFmpeg-devel,1/4] avcodec/vmdaudio: Check chunk counts to avoid integer overflow

Message ID 20191108205710.32295-1-michael@niedermayer.cc
State Accepted
Commit 47d963335eb2c36c0e6615d7971c762458e813dd
Headers show

Commit Message

Michael Niedermayer Nov. 8, 2019, 8:57 p.m. UTC
Fixes: signed integer overflow: 4 * 538976288 cannot be represented in type 'int'
Fixes: 18622/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VMDAUDIO_fuzzer-5092166174507008

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

Comments

Michael Niedermayer Dec. 1, 2019, 2:31 p.m. UTC | #1
On Fri, Nov 08, 2019 at 09:57:07PM +0100, Michael Niedermayer wrote:
> Fixes: signed integer overflow: 4 * 538976288 cannot be represented in type 'int'
> Fixes: 18622/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VMDAUDIO_fuzzer-5092166174507008
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/vmdaudio.c | 3 +++
>  1 file changed, 3 insertions(+)

will apply

[...]
diff mbox

Patch

diff --git a/libavcodec/vmdaudio.c b/libavcodec/vmdaudio.c
index e8c8a064c7..c7826fa3ce 100644
--- a/libavcodec/vmdaudio.c
+++ b/libavcodec/vmdaudio.c
@@ -179,6 +179,9 @@  static int vmdaudio_decode_frame(AVCodecContext *avctx, void *data,
     /* drop incomplete chunks */
     buf_size     = audio_chunks * s->chunk_size;
 
+    if (silent_chunks + audio_chunks >= INT_MAX / avctx->block_align)
+        return AVERROR_INVALIDDATA;
+
     /* get output buffer */
     frame->nb_samples = ((silent_chunks + audio_chunks) * avctx->block_align) /
                         avctx->channels;