diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2016-12-03 03:02:41 +0100 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2016-12-03 04:10:19 +0100 |
commit | 3af916db3705593a4408bb25671a1ecf5dec813f (patch) | |
tree | d107e31bf8137ef777df807f0f5cd2fe909f8f9f | |
parent | 518beeb72f533a54c4a7136643cff5e9a84c646c (diff) | |
download | ffmpeg-3af916db3705593a4408bb25671a1ecf5dec813f.tar.gz |
avformat/utils: Check start/end before computing duration in update_stream_timings()
Fixes undefined behavior
Fixes: 637428.ogg
Found-by: Matt Wolenetz <wolenetz@google.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 90da187f1d334422477886a19eca3c1da29c59a7)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r-- | libavformat/utils.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c index 92b38adb45..a705065879 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2363,11 +2363,14 @@ static void update_stream_timings(AVFormatContext *ic) if (ic->nb_programs) { for (i = 0; i < ic->nb_programs; i++) { p = ic->programs[i]; - if (p->start_time != AV_NOPTS_VALUE && p->end_time > p->start_time) + if (p->start_time != AV_NOPTS_VALUE && + p->end_time > p->start_time && + p->end_time - (uint64_t)p->start_time <= INT64_MAX) duration = FFMAX(duration, p->end_time - p->start_time); } - } else + } else if (end_time >= start_time && end_time - (uint64_t)start_time <= INT64_MAX) { duration = FFMAX(duration, end_time - start_time); + } } } if (duration != INT64_MIN && duration > 0 && ic->duration == AV_NOPTS_VALUE) { |