[FFmpeg-devel,1/6] avcodec/aacdec_template: Check samplerate

Submitted by Michael Niedermayer on Oct. 9, 2019, 10:14 a.m.

Details

Message ID 20191009101454.1608-1-michael@niedermayer.cc
State New
Headers show

Commit Message

Michael Niedermayer Oct. 9, 2019, 10:14 a.m.
A value above INT_MAX/2 can overflow in SBR

Fixes: signed integer overflow: 2 * 1881153568 cannot be represented in type 'int'
Fixes: 17996/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AAC_FIXED_fuzzer-5687126468853760

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

Comments

Moritz Barsnick Oct. 10, 2019, 10:06 a.m.
On Wed, Oct 09, 2019 at 12:14:49 +0200, Michael Niedermayer wrote:
> +    if (avctx->sample_rate > INT_MAX/2)
> +        return AVERROR_INVALIDDATA;

Who enforces the defined sample rates? The demuxer?

I'm trying to say: The maxmimum for AAC is 96000, why not use that?
(Will it ever change? Can it?)

Moritz
Michael Niedermayer Oct. 10, 2019, 12:20 p.m.
On Thu, Oct 10, 2019 at 12:06:43PM +0200, Moritz Barsnick wrote:
> On Wed, Oct 09, 2019 at 12:14:49 +0200, Michael Niedermayer wrote:
> > +    if (avctx->sample_rate > INT_MAX/2)
> > +        return AVERROR_INVALIDDATA;
> 
> Who enforces the defined sample rates? The demuxer?
> 
> I'm trying to say: The maxmimum for AAC is 96000, why not use that?
> (Will it ever change? Can it?)

It certainly could, limits can always change in a revission or extension
but till that happens 96000 is a good choice as limit so ill change it
to that

Thanks


[...]

Patch hide | download patch | download mbox

diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c
index 8726c8b828..75da4eb69a 100644
--- a/libavcodec/aacdec_template.c
+++ b/libavcodec/aacdec_template.c
@@ -1157,6 +1157,9 @@  static av_cold int aac_decode_init(AVCodecContext *avctx)
     AACContext *ac = avctx->priv_data;
     int ret;
 
+    if (avctx->sample_rate > INT_MAX/2)
+        return AVERROR_INVALIDDATA;
+
     ret = ff_thread_once(&aac_table_init, &aac_static_table_init);
     if (ret != 0)
         return AVERROR_UNKNOWN;