]> git.sesse.net Git - ffmpeg/commitdiff
libopusdec: fix out-of-bounds read
authorAndreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Thu, 24 Nov 2016 00:06:35 +0000 (01:06 +0100)
committerVittorio Giovara <vittorio.giovara@gmail.com>
Thu, 8 Dec 2016 20:53:58 +0000 (15:53 -0500)
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
libavcodec/libopusdec.c

index 75eaf9bd48c9e872386811b4db51b1e8b41f713c..781635615c488e0b54a08e1ae528e3f2626b3329 100644 (file)
@@ -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;