aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/dcstr.c
diff options
context:
space:
mode:
authorAndreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>2016-10-20 20:13:54 +0200
committerAndreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>2016-10-21 19:41:09 +0200
commitb0a043f51b8cc3b420dc3ceaa38fe9aa344799aa (patch)
tree43f277e17f8cf76ed600150cfada83cf964b7050 /libavformat/dcstr.c
parent93c39db5f1544d1220488cfeb93bfe812a52f374 (diff)
downloadffmpeg-b0a043f51b8cc3b420dc3ceaa38fe9aa344799aa.tar.gz
dcstr: fix division by zero
Also check for possible overflows. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Diffstat (limited to 'libavformat/dcstr.c')
-rw-r--r--libavformat/dcstr.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/libavformat/dcstr.c b/libavformat/dcstr.c
index 69fae417e8..6035dd4334 100644
--- a/libavformat/dcstr.c
+++ b/libavformat/dcstr.c
@@ -33,6 +33,7 @@ static int dcstr_probe(AVProbeData *p)
static int dcstr_read_header(AVFormatContext *s)
{
unsigned codec, align;
+ int mult;
AVStream *st;
st = avformat_new_stream(s, NULL);
@@ -46,7 +47,12 @@ static int dcstr_read_header(AVFormatContext *s)
align = avio_rl32(s->pb);
avio_skip(s->pb, 4);
st->duration = avio_rl32(s->pb);
- st->codecpar->channels *= avio_rl32(s->pb);
+ mult = avio_rl32(s->pb);
+ if (st->codecpar->channels <= 0 || mult <= 0 || mult > INT_MAX / st->codecpar->channels) {
+ av_log(s, AV_LOG_ERROR, "invalid number of channels %d x %d\n", st->codecpar->channels, mult);
+ return AVERROR_INVALIDDATA;
+ }
+ st->codecpar->channels *= mult;
if (!align || align > INT_MAX / st->codecpar->channels)
return AVERROR_INVALIDDATA;
st->codecpar->block_align = align * st->codecpar->channels;