diff mbox series

[FFmpeg-devel,3/4] avformat/mccdec: Fix overflows in num/den

Message ID 20210424155926.4018-3-michael@niedermayer.cc
State New
Headers show
Series [FFmpeg-devel,1/4] avformat/dxa: Check fps to be within the supported range more precissely
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 April 24, 2021, 3:59 p.m. UTC
Fixes: signed integer overflow: 6365816 * 1000 cannot be represented in type 'int'
Fixes: 29102/clusterfuzz-testcase-minimized-ffmpeg_dem_MCC_fuzzer-6737934184218624

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

Comments

James Almer April 24, 2021, 4:04 p.m. UTC | #1
On 4/24/2021 12:59 PM, Michael Niedermayer wrote:
> Fixes: signed integer overflow: 6365816 * 1000 cannot be represented in type 'int'
> Fixes: 29102/clusterfuzz-testcase-minimized-ffmpeg_dem_MCC_fuzzer-6737934184218624
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>   libavformat/mccdec.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/libavformat/mccdec.c b/libavformat/mccdec.c
> index 2a0b7905a0..7671be61d4 100644
> --- a/libavformat/mccdec.c
> +++ b/libavformat/mccdec.c
> @@ -127,8 +127,7 @@ static int mcc_read_header(AVFormatContext *s)
>                   num = strtol(rate_str, &df, 10);
>                   den = 1;
>                   if (df && !av_strncasecmp(df, "DF", 2)) {
> -                    num *= 1000;
> -                    den  = 1001;
> +                    av_reduce(&num, &den, num * 1000LL, 10001, INT_MAX);

10001?

>                   }
>               }
>   
>
Michael Niedermayer June 17, 2021, 8:55 p.m. UTC | #2
On Sat, Apr 24, 2021 at 01:04:48PM -0300, James Almer wrote:
> On 4/24/2021 12:59 PM, Michael Niedermayer wrote:
> > Fixes: signed integer overflow: 6365816 * 1000 cannot be represented in type 'int'
> > Fixes: 29102/clusterfuzz-testcase-minimized-ffmpeg_dem_MCC_fuzzer-6737934184218624
> > 
> > Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> >   libavformat/mccdec.c | 3 +--
> >   1 file changed, 1 insertion(+), 2 deletions(-)
> > 
> > diff --git a/libavformat/mccdec.c b/libavformat/mccdec.c
> > index 2a0b7905a0..7671be61d4 100644
> > --- a/libavformat/mccdec.c
> > +++ b/libavformat/mccdec.c
> > @@ -127,8 +127,7 @@ static int mcc_read_header(AVFormatContext *s)
> >                   num = strtol(rate_str, &df, 10);
> >                   den = 1;
> >                   if (df && !av_strncasecmp(df, "DF", 2)) {
> > -                    num *= 1000;
> > -                    den  = 1001;
> > +                    av_reduce(&num, &den, num * 1000LL, 10001, INT_MAX);
> 
> 10001?

will apply with a 0 less

thx

[...]
diff mbox series

Patch

diff --git a/libavformat/mccdec.c b/libavformat/mccdec.c
index 2a0b7905a0..7671be61d4 100644
--- a/libavformat/mccdec.c
+++ b/libavformat/mccdec.c
@@ -127,8 +127,7 @@  static int mcc_read_header(AVFormatContext *s)
                 num = strtol(rate_str, &df, 10);
                 den = 1;
                 if (df && !av_strncasecmp(df, "DF", 2)) {
-                    num *= 1000;
-                    den  = 1001;
+                    av_reduce(&num, &den, num * 1000LL, 10001, INT_MAX);
                 }
             }