diff mbox series

[FFmpeg-devel,2/4] fftools/ffmpeg: Fix integer overflow in duration computation in seek_to_start()

Message ID 20200215225105.12141-2-michael@niedermayer.cc
State Accepted
Headers show
Series [FFmpeg-devel,1/4] avfilter/vf_aspect: Fix integer overflow in compute_dar() | expand

Checks

Context Check Description
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Michael Niedermayer Feb. 15, 2020, 10:51 p.m. UTC
Fixes: signed integer overflow: -9223372036854775808 - 9223372036854775807 cannot be represented in type 'long'
Fixes: Ticket8142

Found-by: Suhwan
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 fftools/ffmpeg.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Paul B Mahol Feb. 16, 2020, 11:25 a.m. UTC | #1
probably ok

On 2/15/20, Michael Niedermayer <michael@niedermayer.cc> wrote:
> Fixes: signed integer overflow: -9223372036854775808 - 9223372036854775807
> cannot be represented in type 'long'
> Fixes: Ticket8142
>
> Found-by: Suhwan
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  fftools/ffmpeg.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
> index a43f94bef6..e5fbd479a8 100644
> --- a/fftools/ffmpeg.c
> +++ b/fftools/ffmpeg.c
> @@ -4225,7 +4225,8 @@ static int seek_to_start(InputFile *ifile,
> AVFormatContext *is)
>              ifile->time_base = ist->st->time_base;
>          /* the total duration of the stream, max_pts - min_pts is
>           * the duration of the stream without the last frame */
> -        duration += ist->max_pts - ist->min_pts;
> +        if (ist->max_pts > ist->min_pts && ist->max_pts -
> (uint64_t)ist->min_pts < INT64_MAX - duration)
> +            duration += ist->max_pts - ist->min_pts;
>          ifile->time_base = duration_max(duration, &ifile->duration,
> ist->st->time_base,
>                                          ifile->time_base);
>      }
> --
> 2.17.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Michael Niedermayer Feb. 16, 2020, 2:47 p.m. UTC | #2
On Sun, Feb 16, 2020 at 12:25:45PM +0100, Paul B Mahol wrote:
> probably ok

will apply

thx

[...]
diff mbox series

Patch

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index a43f94bef6..e5fbd479a8 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -4225,7 +4225,8 @@  static int seek_to_start(InputFile *ifile, AVFormatContext *is)
             ifile->time_base = ist->st->time_base;
         /* the total duration of the stream, max_pts - min_pts is
          * the duration of the stream without the last frame */
-        duration += ist->max_pts - ist->min_pts;
+        if (ist->max_pts > ist->min_pts && ist->max_pts - (uint64_t)ist->min_pts < INT64_MAX - duration)
+            duration += ist->max_pts - ist->min_pts;
         ifile->time_base = duration_max(duration, &ifile->duration, ist->st->time_base,
                                         ifile->time_base);
     }