aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/cafdec.c
diff options
context:
space:
mode:
authorAndreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>2016-12-14 01:53:19 +0100
committerAndreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>2016-12-15 01:25:43 +0100
commitbaba9c6aef88727bb0182631dc67744d36cadea4 (patch)
treee38e188379d63ea12171714de8700d30f1e90b67 /libavformat/cafdec.c
parente558a6348ac10e74c54fb50ffd783ff9b5aec050 (diff)
downloadffmpeg-baba9c6aef88727bb0182631dc67744d36cadea4.tar.gz
cafdec: prevent overflow during bit rate calculation
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Diffstat (limited to 'libavformat/cafdec.c')
-rw-r--r--libavformat/cafdec.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/libavformat/cafdec.c b/libavformat/cafdec.c
index 1c4ca401c2..0e6179a56a 100644
--- a/libavformat/cafdec.c
+++ b/libavformat/cafdec.c
@@ -323,8 +323,13 @@ static int read_header(AVFormatContext *s)
if (caf->data_size > 0)
st->nb_frames = (caf->data_size / caf->bytes_per_packet) * caf->frames_per_packet;
} else if (st->nb_index_entries && st->duration > 0) {
- st->codecpar->bit_rate = st->codecpar->sample_rate * caf->data_size * 8 /
- st->duration;
+ if (st->codecpar->sample_rate && caf->data_size / st->duration > INT64_MAX / st->codecpar->sample_rate / 8) {
+ av_log(s, AV_LOG_ERROR, "Overflow during bit rate calculation %d * 8 * %"PRId64"\n",
+ st->codecpar->sample_rate, caf->data_size / st->duration);
+ return AVERROR_INVALIDDATA;
+ }
+ st->codecpar->bit_rate = st->codecpar->sample_rate * 8LL *
+ (caf->data_size / st->duration);
} else {
av_log(s, AV_LOG_ERROR, "Missing packet table. It is required when "
"block size or frame size are variable.\n");