aacdec: check channel count
authorMichael Niedermayer <michaelni@gmx.at>
Sun, 27 Jan 2013 19:37:27 +0000 (20:37 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Thu, 7 Feb 2013 00:00:02 +0000 (01:00 +0100)
Prevent out of array accesses

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 96f452ac647dae33c53c242ef3266b65a9beafb6)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/aacdec.c

index 62df283..34cc18b 100644 (file)
@@ -883,6 +883,11 @@ static av_cold int aac_decode_init(AVCodecContext *avctx)
         }
     }
 
+    if (avctx->channels > MAX_CHANNELS) {
+        av_log(avctx, AV_LOG_ERROR, "Too many channels\n");
+        return AVERROR_INVALIDDATA;
+    }
+
     AAC_INIT_VLC_STATIC( 0, 304);
     AAC_INIT_VLC_STATIC( 1, 270);
     AAC_INIT_VLC_STATIC( 2, 550);