alsdec: check opt_order.
authorMichael Niedermayer <michaelni@gmx.at>
Sat, 24 Mar 2012 00:39:13 +0000 (01:39 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Sat, 24 Mar 2012 13:54:12 +0000 (14:54 +0100)
Fixes out of array write in quant_cof

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/alsdec.c

index 63e58ff..a9b04b8 100644 (file)
@@ -663,6 +663,10 @@ static int read_var_block_data(ALSDecContext *ctx, ALSBlockData *bd)
             int opt_order_length = av_ceil_log2(av_clip((bd->block_length >> 3) - 1,
                                                 2, sconf->max_order + 1));
             *bd->opt_order       = get_bits(gb, opt_order_length);
+            if (*bd->opt_order > sconf->max_order) {
+                av_log(avctx, AV_LOG_ERROR, "Order too large\n");
+                return -1;
+            }
         } else {
             *bd->opt_order = sconf->max_order;
         }