alsdec: limit avctx->bits_per_raw_sample to 32
authorAndreas Cadhalpun <andreas.cadhalpun@googlemail.com>
Sat, 18 Apr 2015 18:29:13 +0000 (20:29 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Sat, 18 Apr 2015 19:00:25 +0000 (21:00 +0200)
avctx->bits_per_raw_sample is used in get_sbits_long, which only
supports up to 32 bits.

Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/alsdec.c

index 030c331..787792f 100644 (file)
@@ -1670,6 +1670,12 @@ static av_cold int decode_init(AVCodecContext *avctx)
         avctx->sample_fmt          = sconf->resolution > 1
                                      ? AV_SAMPLE_FMT_S32 : AV_SAMPLE_FMT_S16;
         avctx->bits_per_raw_sample = (sconf->resolution + 1) * 8;
+        if (avctx->bits_per_raw_sample > 32) {
+            av_log(avctx, AV_LOG_ERROR, "Bits per raw sample %d larger than 32.\n",
+                   avctx->bits_per_raw_sample);
+            ret = AVERROR_INVALIDDATA;
+            goto fail;
+        }
     }
 
     // set maximum Rice parameter for progressive decoding based on resolution