apedec: check bits <= 32
authorMichael Niedermayer <michaelni@gmx.at>
Wed, 28 Mar 2012 06:22:39 +0000 (08:22 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 28 Mar 2012 06:24:31 +0000 (08:24 +0200)
Fixes FPE

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

index 4a69571..907f45f 100644 (file)
@@ -421,9 +421,12 @@ static inline int ape_decode_value(APEContext *ctx, APERice *rice)
 
         if (tmpk <= 16)
             x = range_decode_bits(ctx, tmpk);
-        else {
+        else if (tmpk <= 32) {
             x = range_decode_bits(ctx, 16);
             x |= (range_decode_bits(ctx, tmpk - 16) << 16);
+        } else {
+            av_log(ctx->avctx, AV_LOG_ERROR, "too many bits\n");
+            return -1;
         }
         x += overflow << tmpk;
     } else {