diff mbox series

[FFmpeg-devel,1/5] avformat/mov: We do not support creation times of 300 billion years ago

Message ID 20230525214019.29048-1-michael@niedermayer.cc
State New
Headers show
Series [FFmpeg-devel,1/5] avformat/mov: We do not support creation times of 300 billion years ago | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Michael Niedermayer May 25, 2023, 9:40 p.m. UTC
Fixes: signed integer overflow: -9223372036854775808 - 2082844800 cannot be represented in type 'long'
Fixes: 58384/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-6428383700713472

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

Comments

Marton Balint May 28, 2023, 6:53 p.m. UTC | #1
On Thu, 25 May 2023, Michael Niedermayer wrote:

> Fixes: signed integer overflow: -9223372036854775808 - 2082844800 cannot be represented in type 'long'
> Fixes: 58384/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-6428383700713472
>
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
> libavformat/mov.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index 9fdeef057e..3e2c4bc10d 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -1530,6 +1530,10 @@ static void mov_metadata_creation_time(MOVContext *c, AVIOContext *pb, AVDiction
>         }
>     }
>     if (time) {
> +        if (time < INT64_MIN + 2082844800) {
> +            av_log(c->fc, AV_LOG_DEBUG, "creation_time predates big bang\n");
> +            return;
> +        }

Actually creation_time is unsigned, so it cannot be negative. I suggest 
you simply reject everyting less than 0 here. You should also move the 
check to the version == 1 case, because only that can read a "negative" 
value.

Regards,
Marton
Michael Niedermayer May 28, 2023, 9:03 p.m. UTC | #2
On Sun, May 28, 2023 at 08:53:49PM +0200, Marton Balint wrote:
> 
> 
> On Thu, 25 May 2023, Michael Niedermayer wrote:
> 
> > Fixes: signed integer overflow: -9223372036854775808 - 2082844800 cannot be represented in type 'long'
> > Fixes: 58384/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-6428383700713472
> > 
> > Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> > libavformat/mov.c | 4 ++++
> > 1 file changed, 4 insertions(+)
> > 
> > diff --git a/libavformat/mov.c b/libavformat/mov.c
> > index 9fdeef057e..3e2c4bc10d 100644
> > --- a/libavformat/mov.c
> > +++ b/libavformat/mov.c
> > @@ -1530,6 +1530,10 @@ static void mov_metadata_creation_time(MOVContext *c, AVIOContext *pb, AVDiction
> >         }
> >     }
> >     if (time) {
> > +        if (time < INT64_MIN + 2082844800) {
> > +            av_log(c->fc, AV_LOG_DEBUG, "creation_time predates big bang\n");
> > +            return;
> > +        }
> 
> Actually creation_time is unsigned, so it cannot be negative. I suggest you
> simply reject everyting less than 0 here. You should also move the check to
> the version == 1 case, because only that can read a "negative" value.

ok will apply with these changes

thx

[...]
diff mbox series

Patch

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 9fdeef057e..3e2c4bc10d 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1530,6 +1530,10 @@  static void mov_metadata_creation_time(MOVContext *c, AVIOContext *pb, AVDiction
         }
     }
     if (time) {
+        if (time < INT64_MIN + 2082844800) {
+            av_log(c->fc, AV_LOG_DEBUG, "creation_time predates big bang\n");
+            return;
+        }
         time -= 2082844800;  /* seconds between 1904-01-01 and Epoch */
 
         if ((int64_t)(time * 1000000ULL) / 1000000 != time) {