summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
authorAndreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>2016-11-24 01:06:35 +0100
committerVittorio Giovara <vittorio.giovara@gmail.com>2016-12-08 15:53:58 -0500
commitfc85646ad495f3418042468da415af73a7a07334 (patch)
tree9e0967232874c946189c966c1e2ee3ff0b37fe59 /libavcodec
parentdc2ad094931de2b28c63eaa5614756ed74e2579e (diff)
libopusdec: fix out-of-bounds read
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/libopusdec.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/libavcodec/libopusdec.c b/libavcodec/libopusdec.c
index 75eaf9bd48..781635615c 100644
--- a/libavcodec/libopusdec.c
+++ b/libavcodec/libopusdec.c
@@ -48,6 +48,13 @@ static av_cold int libopus_decode_init(AVCodecContext *avc)
avc->channels = 2;
}
+ avc->channels = avc->extradata_size >= 10 ? avc->extradata[9] : (avc->channels == 1) ? 1 : 2;
+ 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;