diff mbox series

[FFmpeg-devel,2/4] avformat/wtvdec: Check dir_length

Message ID 20201019155955.27725-2-michael@niedermayer.cc
State Accepted
Commit 1868cb731660490beb750389266adb6e68e9123d
Headers show
Series [FFmpeg-devel,1/4] avformat/genh: Check block_align
Related show

Checks

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

Commit Message

Michael Niedermayer Oct. 19, 2020, 3:59 p.m. UTC
Fixes: Infinite loop
Fixes: 26445/clusterfuzz-testcase-minimized-ffmpeg_dem_WTV_fuzzer-5125558331244544

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

Comments

Peter Ross Oct. 19, 2020, 8:54 p.m. UTC | #1
On Mon, Oct 19, 2020 at 05:59:53PM +0200, Michael Niedermayer wrote:
> Fixes: Infinite loop
> Fixes: 26445/clusterfuzz-testcase-minimized-ffmpeg_dem_WTV_fuzzer-5125558331244544
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavformat/wtvdec.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/libavformat/wtvdec.c b/libavformat/wtvdec.c
> index 83f510b92f..77908e6392 100644
> --- a/libavformat/wtvdec.c
> +++ b/libavformat/wtvdec.c
> @@ -273,6 +273,11 @@ static AVIOContext * wtvfile_open2(AVFormatContext *s, const uint8_t *buf, int b
>                     "bad filename length, remaining directory entries ignored\n");
>              break;
>          }
> +        if (dir_length == 0) {
> +            av_log(s, AV_LOG_ERROR,
> +                   "bad dir length, remaining directory entries ignored\n");
> +            break;
> +        }
>          if (48 + (int64_t)name_size > buf_end - buf) {
>              av_log(s, AV_LOG_ERROR, "filename exceeds buffer size; remaining directory entries ignored\n");
>              break;
> -- 

looks good

-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
Michael Niedermayer Oct. 21, 2020, 8:03 a.m. UTC | #2
On Tue, Oct 20, 2020 at 07:54:23AM +1100, Peter Ross wrote:
> On Mon, Oct 19, 2020 at 05:59:53PM +0200, Michael Niedermayer wrote:
> > Fixes: Infinite loop
> > Fixes: 26445/clusterfuzz-testcase-minimized-ffmpeg_dem_WTV_fuzzer-5125558331244544
> > 
> > Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> >  libavformat/wtvdec.c | 5 +++++
> >  1 file changed, 5 insertions(+)
> > 
> > diff --git a/libavformat/wtvdec.c b/libavformat/wtvdec.c
> > index 83f510b92f..77908e6392 100644
> > --- a/libavformat/wtvdec.c
> > +++ b/libavformat/wtvdec.c
> > @@ -273,6 +273,11 @@ static AVIOContext * wtvfile_open2(AVFormatContext *s, const uint8_t *buf, int b
> >                     "bad filename length, remaining directory entries ignored\n");
> >              break;
> >          }
> > +        if (dir_length == 0) {
> > +            av_log(s, AV_LOG_ERROR,
> > +                   "bad dir length, remaining directory entries ignored\n");
> > +            break;
> > +        }
> >          if (48 + (int64_t)name_size > buf_end - buf) {
> >              av_log(s, AV_LOG_ERROR, "filename exceeds buffer size; remaining directory entries ignored\n");
> >              break;
> > -- 
> 
> looks good

will apply

thx

[...]
diff mbox series

Patch

diff --git a/libavformat/wtvdec.c b/libavformat/wtvdec.c
index 83f510b92f..77908e6392 100644
--- a/libavformat/wtvdec.c
+++ b/libavformat/wtvdec.c
@@ -273,6 +273,11 @@  static AVIOContext * wtvfile_open2(AVFormatContext *s, const uint8_t *buf, int b
                    "bad filename length, remaining directory entries ignored\n");
             break;
         }
+        if (dir_length == 0) {
+            av_log(s, AV_LOG_ERROR,
+                   "bad dir length, remaining directory entries ignored\n");
+            break;
+        }
         if (48 + (int64_t)name_size > buf_end - buf) {
             av_log(s, AV_LOG_ERROR, "filename exceeds buffer size; remaining directory entries ignored\n");
             break;