diff options
author | Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com> | 2016-10-20 20:13:54 +0200 |
---|---|---|
committer | Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com> | 2016-11-27 00:38:58 +0100 |
commit | e8ab2bd2ac85ad0b1013f247d35032b7cd7f771e (patch) | |
tree | 774f1dbd503b56a399eba436e81fccca14e644b0 | |
parent | 45b18fbb9a7729c91d69d6359a782a0135b5f2b8 (diff) | |
download | ffmpeg-e8ab2bd2ac85ad0b1013f247d35032b7cd7f771e.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>
(cherry picked from commit b0a043f51b8cc3b420dc3ceaa38fe9aa344799aa)
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
-rw-r--r-- | libavformat/dcstr.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/libavformat/dcstr.c b/libavformat/dcstr.c index 2ae61dec85..e9714e504f 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->codec->channels *= avio_rl32(s->pb); + mult = avio_rl32(s->pb); + if (st->codec->channels <= 0 || mult <= 0 || mult > INT_MAX / st->codec->channels) { + av_log(s, AV_LOG_ERROR, "invalid number of channels %d x %d\n", st->codec->channels, mult); + return AVERROR_INVALIDDATA; + } + st->codec->channels *= mult; if (!align || align > INT_MAX / st->codec->channels) return AVERROR_INVALIDDATA; st->codec->block_align = align * st->codec->channels; |