[FFmpeg-cvslog] estimate_timings_from_bit_rate: Check timebase and bitrate

Michael Niedermayer git at videolan.org
Thu Mar 28 02:11:41 CET 2013


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Thu Mar 28 01:43:55 2013 +0100| [ea9a6709a9412d55012321260f8234253c873491] | committer: Michael Niedermayer

estimate_timings_from_bit_rate: Check timebase and bitrate

Fixes integer overflow and assertion failure

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

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

 libavformat/utils.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index a16f2a6..df688f1 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2325,9 +2325,11 @@ static void estimate_timings_from_bit_rate(AVFormatContext *ic)
         if (filesize > 0) {
             for(i = 0; i < ic->nb_streams; i++) {
                 st = ic->streams[i];
-                duration= av_rescale(8*filesize, st->time_base.den, ic->bit_rate*(int64_t)st->time_base.num);
-                if (st->duration == AV_NOPTS_VALUE)
+                if (   st->time_base.num <= INT64_MAX / ic->bit_rate
+                    && st->duration == AV_NOPTS_VALUE) {
+                    duration= av_rescale(8*filesize, st->time_base.den, ic->bit_rate*(int64_t)st->time_base.num);
                     st->duration = duration;
+                }
             }
         }
     }



More information about the ffmpeg-cvslog mailing list