aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>2016-11-14 21:41:45 +0100
committerAnton Khirnov <anton@khirnov.net>2016-11-23 13:03:15 +0100
commitf92d7bdfddfaac04b3bb31f2749d173ca1d8ba6d (patch)
treef38fe883153ccdab7bb5a7e704012030b7643c63
parentb34c6cd57a2e8aad5f773aea933f77883de320ec (diff)
downloadffmpeg-f92d7bdfddfaac04b3bb31f2749d173ca1d8ba6d.tar.gz
libopusdec: default to stereo for invalid number of channels
This fixes an out-of-bounds read if avc->channels is 0. Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com> Signed-off-by: Anton Khirnov <anton@khirnov.net>
-rw-r--r--libavcodec/libopusdec.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/libavcodec/libopusdec.c b/libavcodec/libopusdec.c
index c6e1573880..75eaf9bd48 100644
--- a/libavcodec/libopusdec.c
+++ b/libavcodec/libopusdec.c
@@ -42,6 +42,12 @@ static av_cold int libopus_decode_init(AVCodecContext *avc)
int ret, channel_map = 0, gain_db = 0, nb_streams, nb_coupled;
uint8_t mapping_arr[8] = { 0, 1 }, *mapping;
+ if (avc->channels <= 0) {
+ av_log(avc, AV_LOG_WARNING,
+ "Invalid number of channels %d, defaulting to stereo\n", avc->channels);
+ avc->channels = 2;
+ }
+
avc->sample_rate = 48000;
avc->sample_fmt = avc->request_sample_fmt == AV_SAMPLE_FMT_FLT ?
AV_SAMPLE_FMT_FLT : AV_SAMPLE_FMT_S16;