diff mbox series

[FFmpeg-devel,3/3] avcodec/mlpdec: add max channels check

Message ID 20220929230927.28439-3-michael@niedermayer.cc
State Accepted
Commit f1f78e3cf4da658225067d9ef35cdb25541e5fe2
Headers show
Series [FFmpeg-devel,1/3] avformat/vividas: Check packet size | expand

Commit Message

Michael Niedermayer Sept. 29, 2022, 11:09 p.m. UTC
Fixes: out of array access
Fixes: 51648/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TRUEHD_fuzzer-4644322217164800

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

Comments

Paul B Mahol Sept. 30, 2022, 8 a.m. UTC | #1
On 9/30/22, Michael Niedermayer <michael@niedermayer.cc> wrote:
> Fixes: out of array access
> Fixes:
> 51648/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TRUEHD_fuzzer-4644322217164800
>


Make sure that this "fix"
does not break Mono.thd decoding.
The sample is on trac ticket.

Thanks.

> Found-by: continuous fuzzing process
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/mlpdec.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c
> index 635f92895c5..0b0eb759901 100644
> --- a/libavcodec/mlpdec.c
> +++ b/libavcodec/mlpdec.c
> @@ -547,6 +547,9 @@ static int read_restart_header(MLPDecodeContext *m,
> GetBitContext *gbp,
>          return AVERROR_PATCHWELCOME;
>      }
>
> +    if (max_channel + 1 > MAX_CHANNELS || max_channel + 1 < min_channel)
> +        return AVERROR_INVALIDDATA;
> +
>      s->min_channel        = min_channel;
>      s->max_channel        = max_channel;
>      s->coded_channels     = ((1LL << (max_channel - min_channel + 1)) - 1)
> << min_channel;
> --
> 2.17.1
>
> _______________________________________________
> 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. 30, 2022, 5:28 p.m. UTC | #2
On Fri, Sep 30, 2022 at 10:00:57AM +0200, Paul B Mahol wrote:
> On 9/30/22, Michael Niedermayer <michael@niedermayer.cc> wrote:
> > Fixes: out of array access
> > Fixes:
> > 51648/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TRUEHD_fuzzer-4644322217164800
> >
> 
> 
> Make sure that this "fix"
> does not break Mono.thd decoding.
> The sample is on trac ticket.

i have tested Mono.thd before posting the patch

thx

[...]
diff mbox series

Patch

diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c
index 635f92895c5..0b0eb759901 100644
--- a/libavcodec/mlpdec.c
+++ b/libavcodec/mlpdec.c
@@ -547,6 +547,9 @@  static int read_restart_header(MLPDecodeContext *m, GetBitContext *gbp,
         return AVERROR_PATCHWELCOME;
     }
 
+    if (max_channel + 1 > MAX_CHANNELS || max_channel + 1 < min_channel)
+        return AVERROR_INVALIDDATA;
+
     s->min_channel        = min_channel;
     s->max_channel        = max_channel;
     s->coded_channels     = ((1LL << (max_channel - min_channel + 1)) - 1) << min_channel;