diff options
author | Dale Curtis <dalecurtis@chromium.org> | 2020-01-28 16:49:14 -0800 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2020-05-19 17:17:35 +0200 |
commit | 9a6d41e9791da9e836086c0dd220ab4f5ec9d8c6 (patch) | |
tree | 30d857fe37c1a60f1e606f85b2f376066824fcc9 | |
parent | 3919ee03ddcb52fbd4a5b0c205ec6ee8b7736625 (diff) | |
download | ffmpeg-9a6d41e9791da9e836086c0dd220ab4f5ec9d8c6.tar.gz |
avformat/utils: Fix undefined behavior in ff_configure_buffers_for_index()
When e2_pts == INT64_MIN and e1_pts >= 0 the calculation of
e2_pts - e1_pts will overflow an int64_t.
Signed-off-by: Dale Curtis <dalecurtis@chromium.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit f15007afa90a3eb3639848d9702c1cc3ac3e896b)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r-- | libavformat/utils.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c index 6c6f4e1bd1..a02789fd85 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2096,6 +2096,8 @@ void ff_configure_buffers_for_index(AVFormatContext *s, int64_t time_tolerance) //We could use URLProtocol flags here but as many user applications do not use URLProtocols this would be unreliable const char *proto = avio_find_protocol_name(s->url); + av_assert0(time_tolerance >= 0); + if (!proto) { av_log(s, AV_LOG_INFO, "Protocol name not provided, cannot determine if input is local or " @@ -2123,7 +2125,7 @@ void ff_configure_buffers_for_index(AVFormatContext *s, int64_t time_tolerance) for (; i2 < st2->nb_index_entries; i2++) { AVIndexEntry *e2 = &st2->index_entries[i2]; int64_t e2_pts = av_rescale_q(e2->timestamp, st2->time_base, AV_TIME_BASE_Q); - if (e2_pts - e1_pts < time_tolerance) + if (e2_pts < e1_pts || e2_pts - (uint64_t)e1_pts < time_tolerance) continue; pos_delta = FFMAX(pos_delta, e1->pos - e2->pos); break; |