[FFmpeg-cvslog] lavf: fix arithmetic overflows in avformat_seek_file()

Mans Rullgard git at videolan.org
Sun Oct 6 19:06:12 CEST 2013


ffmpeg | branch: release/0.7 | Mans Rullgard <mans at mansr.com> | Fri Dec  7 13:53:56 2012 +0000| [c65763a2c677d75388828b9411a69e95bd3ab7af] | committer: Reinhard Tartler

lavf: fix arithmetic overflows in avformat_seek_file()

The values compared here can be more than INT64_MAX apart.  Since the
difference is always positive, converting to uint64_t before subtracting
gives the correct result without overflows.

Signed-off-by: Mans Rullgard <mans at mansr.com>

(cherry picked from commit 91ac403b1316d59b4f43c4ea0f237e24cec2819a)

Signed-off-by: Luca Barbato <lu_zero at gentoo.org>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c65763a2c677d75388828b9411a69e95bd3ab7af
---

 libavformat/utils.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index be67925..b97809f 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -1791,7 +1791,7 @@ int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int
     //Fallback to old API if new is not implemented but old is
     //Note the old has somewat different sematics
     if(s->iformat->read_seek || 1)
-        return av_seek_frame(s, stream_index, ts, flags | (ts - min_ts > (uint64_t)(max_ts - ts) ? AVSEEK_FLAG_BACKWARD : 0));
+        return av_seek_frame(s, stream_index, ts, flags | ((uint64_t)ts - min_ts > (uint64_t)max_ts - ts ? AVSEEK_FLAG_BACKWARD : 0));
 
     // try some generic seek like av_seek_frame_generic() but with new ts semantics
 }



More information about the ffmpeg-cvslog mailing list