diff mbox series

[FFmpeg-devel,1/2] avformat/iff: Check data_size

Message ID 20201211100002.7202-1-michael@niedermayer.cc
State New
Headers show
Series [FFmpeg-devel,1/2] avformat/iff: Check data_size
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished

Commit Message

Michael Niedermayer Dec. 11, 2020, 10 a.m. UTC
Fixes: infinite loop
Fixes: 27834/clusterfuzz-testcase-minimized-ffmpeg_dem_IFF_fuzzer-5694930919620608

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

Comments

Anton Khirnov Dec. 11, 2020, 1:56 p.m. UTC | #1
Quoting Michael Niedermayer (2020-12-11 11:00:01)
> Fixes: infinite loop
> Fixes: 27834/clusterfuzz-testcase-minimized-ffmpeg_dem_IFF_fuzzer-5694930919620608
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavformat/iff.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/libavformat/iff.c b/libavformat/iff.c
> index f017684620..0f570e4b26 100644
> --- a/libavformat/iff.c
> +++ b/libavformat/iff.c
> @@ -402,6 +402,9 @@ static int read_dst_frame(AVFormatContext *s, AVPacket *pkt)
>              break;
>          }
>  
> +        if (data_size >= INT64_MAX)
> +            return AVERROR_INVALIDDATA;

Wouldn't the existing check right above the switch be a more appropriate
place for this?
Michael Niedermayer Dec. 11, 2020, 7:53 p.m. UTC | #2
On Fri, Dec 11, 2020 at 02:56:10PM +0100, Anton Khirnov wrote:
> Quoting Michael Niedermayer (2020-12-11 11:00:01)
> > Fixes: infinite loop
> > Fixes: 27834/clusterfuzz-testcase-minimized-ffmpeg_dem_IFF_fuzzer-5694930919620608
> > 
> > Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> >  libavformat/iff.c | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/libavformat/iff.c b/libavformat/iff.c
> > index f017684620..0f570e4b26 100644
> > --- a/libavformat/iff.c
> > +++ b/libavformat/iff.c
> > @@ -402,6 +402,9 @@ static int read_dst_frame(AVFormatContext *s, AVPacket *pkt)
> >              break;
> >          }
> >  
> > +        if (data_size >= INT64_MAX)
> > +            return AVERROR_INVALIDDATA;
> 
> Wouldn't the existing check right above the switch be a more appropriate
> place for this?

yes, ill merge it in there and will apply

thx

[...]
diff mbox series

Patch

diff --git a/libavformat/iff.c b/libavformat/iff.c
index f017684620..0f570e4b26 100644
--- a/libavformat/iff.c
+++ b/libavformat/iff.c
@@ -402,6 +402,9 @@  static int read_dst_frame(AVFormatContext *s, AVPacket *pkt)
             break;
         }
 
+        if (data_size >= INT64_MAX)
+            return AVERROR_INVALIDDATA;
+
         avio_skip(pb, data_size - (avio_tell(pb) - data_pos) + (data_size & 1));
     }