diff mbox series

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

Message ID 20200927202053.7502-1-michael@niedermayer.cc
State Accepted
Commit 24352ca79207d3311ee544fcba908a64004763ef
Headers show
Series [FFmpeg-devel,1/2] avformat/iff: Check data_size not overflowing int64 | 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. 27, 2020, 8:20 p.m. UTC
Fixes: Infinite loop
Fixes: 25844/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5660803318153216

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

Peter Ross Sept. 27, 2020, 10:30 p.m. UTC | #1
On Sun, Sep 27, 2020 at 10:20:52PM +0200, Michael Niedermayer wrote:
> Fixes: Infinite loop
> Fixes: 25844/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5660803318153216
> 
> 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 7feb121cd0..04fe8be4eb 100644
> --- a/libavformat/iff.c
> +++ b/libavformat/iff.c
> @@ -449,6 +449,9 @@ static int iff_read_header(AVFormatContext *s)
>          data_size = iff->is_64bit ? avio_rb64(pb) : avio_rb32(pb);
>          orig_pos = avio_tell(pb);
>  
> +        if (data_size >= INT64_MAX)
> +            return AVERROR_INVALIDDATA;
> +
>          switch(chunk_id) {
>          case ID_VHDR:
>              st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
> -- 
> 2.17.1

ok

-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
Michael Niedermayer Sept. 28, 2020, 6:20 p.m. UTC | #2
On Mon, Sep 28, 2020 at 08:30:50AM +1000, Peter Ross wrote:
> On Sun, Sep 27, 2020 at 10:20:52PM +0200, Michael Niedermayer wrote:
> > Fixes: Infinite loop
> > Fixes: 25844/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5660803318153216
> > 
> > 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 7feb121cd0..04fe8be4eb 100644
> > --- a/libavformat/iff.c
> > +++ b/libavformat/iff.c
> > @@ -449,6 +449,9 @@ static int iff_read_header(AVFormatContext *s)
> >          data_size = iff->is_64bit ? avio_rb64(pb) : avio_rb32(pb);
> >          orig_pos = avio_tell(pb);
> >  
> > +        if (data_size >= INT64_MAX)
> > +            return AVERROR_INVALIDDATA;
> > +
> >          switch(chunk_id) {
> >          case ID_VHDR:
> >              st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
> > -- 
> > 2.17.1
> 
> ok

will apply

thx

[...]
Michael Niedermayer Oct. 17, 2020, 9:04 a.m. UTC | #3
On Sun, Sep 27, 2020 at 10:20:53PM +0200, Michael Niedermayer wrote:
> Fixes: off by 1 error
> Fixes: index 5 out of bounds for type 'COOKSubpacket [5]'
> Fixes: 25772/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_COOK_fuzzer-5762459498184704.fuzz
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/cook.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)

will apply

[...]
diff mbox series

Patch

diff --git a/libavformat/iff.c b/libavformat/iff.c
index 7feb121cd0..04fe8be4eb 100644
--- a/libavformat/iff.c
+++ b/libavformat/iff.c
@@ -449,6 +449,9 @@  static int iff_read_header(AVFormatContext *s)
         data_size = iff->is_64bit ? avio_rb64(pb) : avio_rb32(pb);
         orig_pos = avio_tell(pb);
 
+        if (data_size >= INT64_MAX)
+            return AVERROR_INVALIDDATA;
+
         switch(chunk_id) {
         case ID_VHDR:
             st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;