diff mbox series

[FFmpeg-devel,1/7] avformat/ads: Check size

Message ID 20210114225116.13486-1-michael@niedermayer.cc
State Accepted
Commit c78b2b138ce222de2f4cecac8fd4361f05ee9428
Headers show
Series [FFmpeg-devel,1/7] avformat/ads: Check size
Related show

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 Jan. 14, 2021, 10:51 p.m. UTC
Fixes: signed integer overflow: -2147483616 - 64 cannot be represented in type 'int'
Fixes: 26910/clusterfuzz-testcase-minimized-ffmpeg_dem_ADS_fuzzer-6617769344892928

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

Comments

Michael Niedermayer Jan. 23, 2021, 12:11 a.m. UTC | #1
On Thu, Jan 14, 2021 at 11:51:10PM +0100, Michael Niedermayer wrote:
> Fixes: signed integer overflow: -2147483616 - 64 cannot be represented in type 'int'
> Fixes: 26910/clusterfuzz-testcase-minimized-ffmpeg_dem_ADS_fuzzer-6617769344892928
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavformat/ads.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)

will apply

[...]
diff mbox series

Patch

diff --git a/libavformat/ads.c b/libavformat/ads.c
index f25141b3c6..544d652829 100644
--- a/libavformat/ads.c
+++ b/libavformat/ads.c
@@ -34,8 +34,9 @@  static int ads_probe(const AVProbeData *p)
 
 static int ads_read_header(AVFormatContext *s)
 {
-    int align, codec, size;
+    int align, codec;
     AVStream *st;
+    int64_t size;
 
     st = avformat_new_stream(s, NULL);
     if (!st)
@@ -62,7 +63,7 @@  static int ads_read_header(AVFormatContext *s)
     st->codecpar->block_align = st->codecpar->channels * align;
     avio_skip(s->pb, 12);
     size = avio_rl32(s->pb);
-    if (st->codecpar->codec_id == AV_CODEC_ID_ADPCM_PSX)
+    if (st->codecpar->codec_id == AV_CODEC_ID_ADPCM_PSX && size >= 0x40)
         st->duration = (size - 0x40) / 16 / st->codecpar->channels * 28;
     avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);