Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2016-12-03 05:02:41 +0300
committerMichael Niedermayer <michael@niedermayer.cc>2016-12-06 02:07:50 +0300
commita0ed412f38f5b65f530528a7969ca3a9d3269be8 (patch)
treefc401acf86b50f7cf57f425d48f74e26b60e32fe /libavformat
parent2fb7eb05dcac0469cec52372f2cdb9d15d5926ae (diff)
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>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/utils.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c
index a89820d85e..5348e0d493 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2597,11 +2597,14 @@ static void update_stream_timings(AVFormatContext *ic)
if (ic->nb_programs > 1) {
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) {