[FFmpeg-devel,1/3] avformat/vpk: Fix integer overflow in samples_per_block computation

Submitted by Michael Niedermayer on June 6, 2019, 9:50 p.m.

Details

Message ID 20190606215059.6935-1-michael@niedermayer.cc
State Accepted
Commit 8c6c4129b4cc3b9e0b3a527a5a15c904ec6ae3b6
Headers show

Commit Message

Michael Niedermayer June 6, 2019, 9:50 p.m.
Fixes: signed integer overflow: 84026453 * 28 cannot be represented in type 'int'
Fixes: 15111/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5675630072430592

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

Comments

Michael Niedermayer June 13, 2019, 8:48 p.m.
On Thu, Jun 06, 2019 at 11:50:57PM +0200, Michael Niedermayer wrote:
> Fixes: signed integer overflow: 84026453 * 28 cannot be represented in type 'int'
> Fixes: 15111/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5675630072430592
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavformat/vpk.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

will apply patchset

[...]

Patch hide | download patch | download mbox

diff --git a/libavformat/vpk.c b/libavformat/vpk.c
index 1dfb8fcd70..dcc2db329c 100644
--- a/libavformat/vpk.c
+++ b/libavformat/vpk.c
@@ -56,12 +56,12 @@  static int vpk_read_header(AVFormatContext *s)
     st->codecpar->codec_id    = AV_CODEC_ID_ADPCM_PSX;
     st->codecpar->block_align = avio_rl32(s->pb);
     st->codecpar->sample_rate = avio_rl32(s->pb);
-    if (st->codecpar->sample_rate <= 0)
+    if (st->codecpar->sample_rate <= 0 || st->codecpar->block_align <= 0)
         return AVERROR_INVALIDDATA;
     st->codecpar->channels    = avio_rl32(s->pb);
     if (st->codecpar->channels <= 0)
         return AVERROR_INVALIDDATA;
-    samples_per_block      = ((st->codecpar->block_align / st->codecpar->channels) * 28) / 16;
+    samples_per_block      = ((st->codecpar->block_align / st->codecpar->channels) * 28LL) / 16;
     if (samples_per_block <= 0)
         return AVERROR_INVALIDDATA;
     vpk->block_count       = (st->duration + (samples_per_block - 1)) / samples_per_block;