libopusenc: prevent an out-of-bounds read by returning early
authorVittorio Giovara <vittorio.giovara@gmail.com>
Tue, 11 Nov 2014 12:26:55 +0000 (13:26 +0100)
committerVittorio Giovara <vittorio.giovara@gmail.com>
Thu, 13 Nov 2014 00:41:25 +0000 (01:41 +0100)
CC: libav-stable@libav.org
Bug-Id: CID 1244188

libavcodec/libopusenc.c

index 84472068edd52b9d551ddcc9193436b7df9cda53..da6194acac2f66de453ac1e5d069c748b5bd7e21 100644 (file)
@@ -163,10 +163,11 @@ static int av_cold libopus_encode_init(AVCodecContext *avctx)
 
     /* FIXME: Opus can handle up to 255 channels. However, the mapping for
      * anything greater than 8 is undefined. */
-    if (avctx->channels > 8)
-        av_log(avctx, AV_LOG_WARNING,
+    if (avctx->channels > 8) {
+        av_log(avctx, AV_LOG_ERROR,
                "Channel layout undefined for %d channels.\n", avctx->channels);
-
+        return AVERROR_PATCHWELCOME;
+    }
     if (!avctx->bit_rate) {
         /* Sane default copied from opusenc */
         avctx->bit_rate = 64000 * opus->stream_count +