[FFmpeg-cvslog] lavf: avoid integer overflow when estimating bitrate

Anton Khirnov git at videolan.org
Thu Sep 26 00:26:08 CEST 2013


ffmpeg | branch: release/0.10 | Anton Khirnov <anton at khirnov.net> | Sat Aug 24 21:30:46 2013 +0200| [8d2a86a29055d375eed9c1e93983f42c42fe856d] | committer: Sean McGovern

lavf: avoid integer overflow when estimating bitrate

Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable at libav.org
(cherry picked from commit df33a58e5311ee9a64a573889b883a80e981af7b)
Signed-off-by: Luca Barbato <lu_zero at gentoo.org>

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

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

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 98c3af4..e31c579 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -1953,8 +1953,13 @@ static void estimate_timings_from_bit_rate(AVFormatContext *ic)
         bit_rate = 0;
         for(i=0;i<ic->nb_streams;i++) {
             st = ic->streams[i];
-            if (st->codec->bit_rate > 0)
-            bit_rate += st->codec->bit_rate;
+            if (st->codec->bit_rate > 0) {
+                if (INT_MAX - st->codec->bit_rate > bit_rate) {
+                    bit_rate = 0;
+                    break;
+                }
+                bit_rate += st->codec->bit_rate;
+            }
         }
         ic->bit_rate = bit_rate;
     }



More information about the ffmpeg-cvslog mailing list