[FFmpeg-cvslog] lavf: Make sure avg_frame_rate can be calculated without integer overflow

Martin Storsjö git at videolan.org
Tue Aug 27 18:38:48 CEST 2013


ffmpeg | branch: release/1.1 | Martin Storsjö <martin at martin.st> | Mon Jul 15 16:44:20 2013 +0300| [dc556d8bf71d7cf463fb14234707e827f790818c] | committer: Luca Barbato

lavf: Make sure avg_frame_rate can be calculated without integer overflow

If either of the deltas is too large for the multiplications to
succeed, don't use this for setting the avg frame rate.

Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Cc: libav-stable at libav.org
Signed-off-by: Martin Storsjö <martin at martin.st>
(cherry picked from commit e740929a071ab032ffa382e89da69c6ec7cf882c)

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

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

 libavformat/utils.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 085ae83..e1511ee 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2493,6 +2493,9 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
                 int      best_fps = 0;
                 double best_error = 0.01;
 
+                if (delta_dts     >= INT64_MAX / st->time_base.num ||
+                    delta_packets >= INT64_MAX / st->time_base.den)
+                    continue;
                 av_reduce(&st->avg_frame_rate.num, &st->avg_frame_rate.den,
                           delta_packets*(int64_t)st->time_base.den,
                           delta_dts*(int64_t)st->time_base.num, 60000);



More information about the ffmpeg-cvslog mailing list