aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Cadhalpun <andreas.cadhalpun@googlemail.com>2015-05-04 21:07:52 +0200
committerAndreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>2015-11-26 01:38:16 +0100
commit045121959e20db1e66da9e3934fa70cd20f5a4f2 (patch)
treea9436eac0d6c80b2adfaca8e0a84629c86894dcb
parentd837407ae0bcdfe676713c16871daadddc99649f (diff)
downloadffmpeg-045121959e20db1e66da9e3934fa70cd20f5a4f2.tar.gz
avidec: check for valid bit_rate range
If bit_rate is negative, it can trigger an av_assert2 in av_rescale_rnd. Since av_rescale returns int64_t, but st->codec_bit_rate is int, it can also overflow into a negative value. Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at> (cherry picked from commit 0eec40b713eee84e2aec8af35ccce059817cad2a) Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
-rw-r--r--libavformat/avidec.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/libavformat/avidec.c b/libavformat/avidec.c
index 7387217ce9..417fb74398 100644
--- a/libavformat/avidec.c
+++ b/libavformat/avidec.c
@@ -447,6 +447,7 @@ static int calculate_bitrate(AVFormatContext *s)
int64_t len = 0;
AVStream *st = s->streams[i];
int64_t duration;
+ int64_t bitrate;
for (j = 0; j < st->nb_index_entries; j++)
len += st->index_entries[j].size;
@@ -454,7 +455,10 @@ static int calculate_bitrate(AVFormatContext *s)
if (st->nb_index_entries < 2 || st->codec->bit_rate > 0)
continue;
duration = st->index_entries[j-1].timestamp - st->index_entries[0].timestamp;
- st->codec->bit_rate = av_rescale(8*len, st->time_base.den, duration * st->time_base.num);
+ bitrate = av_rescale(8*len, st->time_base.den, duration * st->time_base.num);
+ if (bitrate <= INT_MAX && bitrate > 0) {
+ st->codec->bit_rate = bitrate;
+ }
}
return 1;
}