History

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.

Dale Curtis committed 6 years ago

Commit f15007a1 parent f3bb5921 file · +3 −1Browse files

Unified · Split

libavformat/utils.c+3−1
@@ -2108,6 +2108,8 @@ void ff_configure_buffers_for_index(AVFormatContext *s, int64_t time_tolerance) · 2107 unmodified lines
2108 //We could use URLProtocol flags here but as many user applications do not use URLProtocols this would be unreliable2108 //We could use URLProtocol flags here but as many user applications do not use URLProtocols this would be unreliable
2109 const char *proto = avio_find_protocol_name(s->url);2109 const char *proto = avio_find_protocol_name(s->url);
2110 2110
2111 av_assert0(time_tolerance >= 0);
2112
2111 if (!proto) {2113 if (!proto) {
2112 av_log(s, AV_LOG_INFO,2114 av_log(s, AV_LOG_INFO,
2113 "Protocol name not provided, cannot determine if input is local or "2115 "Protocol name not provided, cannot determine if input is local or "
@@ -2135,7 +2137,7 @@ void ff_configure_buffers_for_index(AVFormatContext *s, int64_t time_tolerance) · 21 unmodified lines
2135 for (; i2 < st2->nb_index_entries; i2++) {2137 for (; i2 < st2->nb_index_entries; i2++) {
2136 AVIndexEntry *e2 = &st2->index_entries[i2];2138 AVIndexEntry *e2 = &st2->index_entries[i2];
2137 int64_t e2_pts = av_rescale_q(e2->timestamp, st2->time_base, AV_TIME_BASE_Q);2139 int64_t e2_pts = av_rescale_q(e2->timestamp, st2->time_base, AV_TIME_BASE_Q);
2138 if (e2_pts - e1_pts < time_tolerance)2140 if (e2_pts < e1_pts || e2_pts - (uint64_t)e1_pts < time_tolerance)
2139 continue;2141 continue;
2140 pos_delta = FFMAX(pos_delta, e1->pos - e2->pos);2142 pos_delta = FFMAX(pos_delta, e1->pos - e2->pos);
2141 break;2143 break;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t