diff mbox series

[FFmpeg-devel,3/5] avcodec/apac: Sanity check bits_per_coded_sample

Message ID 20221218170823.32130-3-michael@niedermayer.cc
State New
Headers show
Series [FFmpeg-devel,1/5] avcodec/tiff: Check camera_calibration for 0 | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Michael Niedermayer Dec. 18, 2022, 5:08 p.m. UTC
Fixes: signed integer overflow: 2147483647 + 1 cannot be represented in type 'int'
Fixes: 53931/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APAC_fuzzer-6072913738727424

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

Comments

Paul B Mahol Dec. 19, 2022, 7:35 p.m. UTC | #1
On 12/18/22, Michael Niedermayer <michael@niedermayer.cc> wrote:
> Fixes: signed integer overflow: 2147483647 + 1 cannot be represented in type
> 'int'
> Fixes:
> 53931/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APAC_fuzzer-6072913738727424
>
> Found-by: continuous fuzzing process
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/apac.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/libavcodec/apac.c b/libavcodec/apac.c
> index 030f81adce..2501209681 100644
> --- a/libavcodec/apac.c
> +++ b/libavcodec/apac.c
> @@ -75,7 +75,9 @@ static av_cold int apac_init(AVCodecContext *avctx)
>          avctx->sample_fmt = AV_SAMPLE_FMT_U8P;
>
>      if (avctx->ch_layout.nb_channels < 1 ||
> -        avctx->ch_layout.nb_channels > 2)
> +        avctx->ch_layout.nb_channels > 2 ||
> +        avctx->bits_per_coded_sample > 32U
> +    )
>          return AVERROR_INVALIDDATA;
>
>      for (int ch = 0; ch < avctx->ch_layout.nb_channels; ch++) {
> --
> 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".
>

Pretty sure bps cant be <8 and >16
Michael Niedermayer Dec. 20, 2022, 5:13 p.m. UTC | #2
On Mon, Dec 19, 2022 at 08:35:45PM +0100, Paul B Mahol wrote:
> On 12/18/22, Michael Niedermayer <michael@niedermayer.cc> wrote:
> > Fixes: signed integer overflow: 2147483647 + 1 cannot be represented in type
> > 'int'
> > Fixes:
> > 53931/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APAC_fuzzer-6072913738727424
> >
> > Found-by: continuous fuzzing process
> > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> >  libavcodec/apac.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/libavcodec/apac.c b/libavcodec/apac.c
> > index 030f81adce..2501209681 100644
> > --- a/libavcodec/apac.c
> > +++ b/libavcodec/apac.c
> > @@ -75,7 +75,9 @@ static av_cold int apac_init(AVCodecContext *avctx)
> >          avctx->sample_fmt = AV_SAMPLE_FMT_U8P;
> >
> >      if (avctx->ch_layout.nb_channels < 1 ||
> > -        avctx->ch_layout.nb_channels > 2)
> > +        avctx->ch_layout.nb_channels > 2 ||
> > +        avctx->bits_per_coded_sample > 32U
> > +    )
> >          return AVERROR_INVALIDDATA;
> >
> >      for (int ch = 0; ch < avctx->ch_layout.nb_channels; ch++) {
> > --
> > 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".
> >
> 
> Pretty sure bps cant be <8 and >16

ok, will apply <8  || >16 check then

thx

[...]
diff mbox series

Patch

diff --git a/libavcodec/apac.c b/libavcodec/apac.c
index 030f81adce..2501209681 100644
--- a/libavcodec/apac.c
+++ b/libavcodec/apac.c
@@ -75,7 +75,9 @@  static av_cold int apac_init(AVCodecContext *avctx)
         avctx->sample_fmt = AV_SAMPLE_FMT_U8P;
 
     if (avctx->ch_layout.nb_channels < 1 ||
-        avctx->ch_layout.nb_channels > 2)
+        avctx->ch_layout.nb_channels > 2 ||
+        avctx->bits_per_coded_sample > 32U
+    )
         return AVERROR_INVALIDDATA;
 
     for (int ch = 0; ch < avctx->ch_layout.nb_channels; ch++) {