diff mbox series

[FFmpeg-devel,3/4] avformat/moflex: Check pop_int() for overflow

Message ID 20200920202608.11653-3-michael@niedermayer.cc
State Accepted
Commit dfbea7b210ac95e59446f9512b25688df44c108b
Headers show
Series [FFmpeg-devel,1/4] avformat/wvdec: Check rate for overflow | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Michael Niedermayer Sept. 20, 2020, 8:26 p.m. UTC
Fixes: signed integer overflow: 2 * 2132811776 cannot be represented in type 'int'
Fixes: 25722/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-6221704077246464

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

Comments

Paul B Mahol Sept. 20, 2020, 10:32 p.m. UTC | #1
On Sun, Sep 20, 2020 at 10:26:07PM +0200, Michael Niedermayer wrote:
> Fixes: signed integer overflow: 2 * 2132811776 cannot be represented in type 'int'
> Fixes: 25722/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-6221704077246464
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavformat/moflex.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/libavformat/moflex.c b/libavformat/moflex.c
> index 2111157408..937f63cb63 100644
> --- a/libavformat/moflex.c
> +++ b/libavformat/moflex.c
> @@ -62,6 +62,8 @@ static int pop_int(BitReader *br, AVIOContext *pb, int n)
>  
>          if (ret < 0)
>              return ret;
> +        if (ret > INT_MAX - value - value)
> +            return AVERROR_INVALIDDATA;
>          value = 2 * value + ret;

Generally acceptable.
Michael Niedermayer Sept. 21, 2020, 9:57 a.m. UTC | #2
On Mon, Sep 21, 2020 at 12:32:14AM +0200, Paul B Mahol wrote:
> On Sun, Sep 20, 2020 at 10:26:07PM +0200, Michael Niedermayer wrote:
> > Fixes: signed integer overflow: 2 * 2132811776 cannot be represented in type 'int'
> > Fixes: 25722/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-6221704077246464
> > 
> > Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> >  libavformat/moflex.c | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/libavformat/moflex.c b/libavformat/moflex.c
> > index 2111157408..937f63cb63 100644
> > --- a/libavformat/moflex.c
> > +++ b/libavformat/moflex.c
> > @@ -62,6 +62,8 @@ static int pop_int(BitReader *br, AVIOContext *pb, int n)
> >  
> >          if (ret < 0)
> >              return ret;
> > +        if (ret > INT_MAX - value - value)
> > +            return AVERROR_INVALIDDATA;
> >          value = 2 * value + ret;
> 
> Generally acceptable.

will apply

thx

[...]
diff mbox series

Patch

diff --git a/libavformat/moflex.c b/libavformat/moflex.c
index 2111157408..937f63cb63 100644
--- a/libavformat/moflex.c
+++ b/libavformat/moflex.c
@@ -62,6 +62,8 @@  static int pop_int(BitReader *br, AVIOContext *pb, int n)
 
         if (ret < 0)
             return ret;
+        if (ret > INT_MAX - value - value)
+            return AVERROR_INVALIDDATA;
         value = 2 * value + ret;
     }