diff mbox

[FFmpeg-devel,2/2] avcodec/qdm2: Check frame size

Message ID 20190829194632.3918-2-michael@niedermayer.cc
State Accepted
Commit 12b909ba319d32ed100d9b26021aa9b6976424d7
Headers show

Commit Message

Michael Niedermayer Aug. 29, 2019, 7:46 p.m. UTC
Fixes: index 2304 out of bounds for type 'float [2304]'
Fixes: 16332/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_QDM2_fuzzer-5679142481166336

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

Comments

Michael Niedermayer Sept. 6, 2019, 8:29 p.m. UTC | #1
On Thu, Aug 29, 2019 at 09:46:32PM +0200, Michael Niedermayer wrote:
> Fixes: index 2304 out of bounds for type 'float [2304]'
> Fixes: 16332/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_QDM2_fuzzer-5679142481166336
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/qdm2.c | 5 +++++
>  1 file changed, 5 insertions(+)

will apply

[...]
Paul B Mahol Sept. 6, 2019, 9:08 p.m. UTC | #2
Are you sure this is not band aid but actually real fix?

On 8/29/19, Michael Niedermayer <michael@niedermayer.cc> wrote:
> Fixes: index 2304 out of bounds for type 'float [2304]'
> Fixes:
> 16332/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_QDM2_fuzzer-5679142481166336
>
> Found-by: continuous fuzzing process
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/qdm2.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/libavcodec/qdm2.c b/libavcodec/qdm2.c
> index eaffb36dcc..ac8ae8cbbb 100644
> --- a/libavcodec/qdm2.c
> +++ b/libavcodec/qdm2.c
> @@ -1727,6 +1727,11 @@ static av_cold int qdm2_decode_init(AVCodecContext
> *avctx)
>      s->sub_sampling = s->fft_order - 7;
>      s->frequency_range = 255 / (1 << (2 - s->sub_sampling));
>
> +    if (s->frame_size * 4 >> s->sub_sampling > MPA_FRAME_SIZE) {
> +        avpriv_request_sample(avctx, "large frames");
> +        return AVERROR_PATCHWELCOME;
> +    }
> +
>      switch ((s->sub_sampling * 2 + s->channels - 1)) {
>          case 0: tmp = 40; break;
>          case 1: tmp = 48; break;
> --
> 2.23.0
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Michael Niedermayer Sept. 7, 2019, 2:39 p.m. UTC | #3
On Fri, Sep 06, 2019 at 11:08:06PM +0200, Paul B Mahol wrote:
> Are you sure this is not band aid but actually real fix?

Sorry, I did not see your reply yesterday before applying the change.

Without a real (non fuzzer) sample and no reference specification or 
reference implementation that is open source. Asking for a sample 
seems the obvious solution to me. Having a sample for this case would
be quite usefull ...

I do not know if this corner case ever occurs in a real sample,
but if it does occur then yes this is not a real fix for it, 
it just avoids the anomaly found by the fuzzer.
If this never occurs in any encoder output then it would be a
real fix. (minus asking for a sample)

Thanks

> 
> On 8/29/19, Michael Niedermayer <michael@niedermayer.cc> wrote:
> > Fixes: index 2304 out of bounds for type 'float [2304]'
> > Fixes:
> > 16332/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_QDM2_fuzzer-5679142481166336
> >
> > Found-by: continuous fuzzing process
> > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> >  libavcodec/qdm2.c | 5 +++++
> >  1 file changed, 5 insertions(+)
> >
> > diff --git a/libavcodec/qdm2.c b/libavcodec/qdm2.c
> > index eaffb36dcc..ac8ae8cbbb 100644
> > --- a/libavcodec/qdm2.c
> > +++ b/libavcodec/qdm2.c
> > @@ -1727,6 +1727,11 @@ static av_cold int qdm2_decode_init(AVCodecContext
> > *avctx)
> >      s->sub_sampling = s->fft_order - 7;
> >      s->frequency_range = 255 / (1 << (2 - s->sub_sampling));
> >
> > +    if (s->frame_size * 4 >> s->sub_sampling > MPA_FRAME_SIZE) {
> > +        avpriv_request_sample(avctx, "large frames");
> > +        return AVERROR_PATCHWELCOME;
> > +    }
> > +
> >      switch ((s->sub_sampling * 2 + s->channels - 1)) {
> >          case 0: tmp = 40; break;
> >          case 1: tmp = 48; break;
> > --
> > 2.23.0
> >
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> > To unsubscribe, visit link above, or email
> > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
diff mbox

Patch

diff --git a/libavcodec/qdm2.c b/libavcodec/qdm2.c
index eaffb36dcc..ac8ae8cbbb 100644
--- a/libavcodec/qdm2.c
+++ b/libavcodec/qdm2.c
@@ -1727,6 +1727,11 @@  static av_cold int qdm2_decode_init(AVCodecContext *avctx)
     s->sub_sampling = s->fft_order - 7;
     s->frequency_range = 255 / (1 << (2 - s->sub_sampling));
 
+    if (s->frame_size * 4 >> s->sub_sampling > MPA_FRAME_SIZE) {
+        avpriv_request_sample(avctx, "large frames");
+        return AVERROR_PATCHWELCOME;
+    }
+
     switch ((s->sub_sampling * 2 + s->channels - 1)) {
         case 0: tmp = 40; break;
         case 1: tmp = 48; break;