diff options
author | Anton Khirnov <anton@khirnov.net> | 2013-08-24 21:30:46 +0200 |
---|---|---|
committer | Sean McGovern <gseanmcg@gmail.com> | 2013-09-23 19:47:41 -0400 |
commit | 8d2a86a29055d375eed9c1e93983f42c42fe856d (patch) | |
tree | 9582cf8343169d44e78b9b597d43feb5ba0a44ba | |
parent | 5773065a71055b5000717fab68e79647eea3dd6d (diff) | |
download | ffmpeg-8d2a86a29055d375eed9c1e93983f42c42fe856d.tar.gz |
lavf: avoid integer overflow when estimating bitrate
Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
(cherry picked from commit df33a58e5311ee9a64a573889b883a80e981af7b)
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
-rw-r--r-- | libavformat/utils.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c index 98c3af4e83..e31c5799e7 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; } |