aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-12-12 12:28:45 +0100
committerMichael Niedermayer <michaelni@gmx.at>2013-02-17 23:22:12 +0100
commit760929117df0d6349a2cb56af084d8a13ee7f33a (patch)
tree09b84320283cbebe5208d63742f0c794e5736651
parentacada70ffbd729516495ee683f70abad124f93d5 (diff)
downloadffmpeg-760929117df0d6349a2cb56af084d8a13ee7f33a.tar.gz
alsdec: check block length
Fix writing over the end Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer <michaelni@gmx.at> (cherry picked from commit 0ceca269b66ec12a23bf0907bd2c220513cdbf16) Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavcodec/alsdec.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c
index cb679d9955..8cb5a6089c 100644
--- a/libavcodec/alsdec.c
+++ b/libavcodec/alsdec.c
@@ -551,12 +551,15 @@ static void get_block_sizes(ALSDecContext *ctx, unsigned int *div_blocks,
/** Read the block data for a constant block
*/
-static void read_const_block_data(ALSDecContext *ctx, ALSBlockData *bd)
+static int read_const_block_data(ALSDecContext *ctx, ALSBlockData *bd)
{
ALSSpecificConfig *sconf = &ctx->sconf;
AVCodecContext *avctx = ctx->avctx;
GetBitContext *gb = &ctx->gb;
+ if (bd->block_length <= 0)
+ return -1;
+
*bd->raw_samples = 0;
*bd->const_block = get_bits1(gb); // 1 = constant value, 0 = zero block (silence)
bd->js_blocks = get_bits1(gb);
@@ -571,6 +574,8 @@ static void read_const_block_data(ALSDecContext *ctx, ALSBlockData *bd)
// ensure constant block decoding by reusing this field
*bd->const_block = 1;
+
+ return 0;
}
@@ -970,7 +975,8 @@ static int read_block(ALSDecContext *ctx, ALSBlockData *bd)
if (read_var_block_data(ctx, bd))
return -1;
} else {
- read_const_block_data(ctx, bd);
+ if (read_const_block_data(ctx, bd) < 0)
+ return -1;
}
return 0;