Commit ce7d842f authored by Justin Ruggles's avatar Justin Ruggles

ac3dec: detect out-of-range exponents

Originally committed as revision 16015 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent d8b66635
...@@ -372,7 +372,7 @@ static void set_downmix_coeffs(AC3DecodeContext *s) ...@@ -372,7 +372,7 @@ static void set_downmix_coeffs(AC3DecodeContext *s)
* Decode the grouped exponents according to exponent strategy. * Decode the grouped exponents according to exponent strategy.
* reference: Section 7.1.3 Exponent Decoding * reference: Section 7.1.3 Exponent Decoding
*/ */
static void decode_exponents(GetBitContext *gbc, int exp_strategy, int ngrps, static int decode_exponents(GetBitContext *gbc, int exp_strategy, int ngrps,
uint8_t absexp, int8_t *dexps) uint8_t absexp, int8_t *dexps)
{ {
int i, j, grp, group_size; int i, j, grp, group_size;
...@@ -391,11 +391,14 @@ static void decode_exponents(GetBitContext *gbc, int exp_strategy, int ngrps, ...@@ -391,11 +391,14 @@ static void decode_exponents(GetBitContext *gbc, int exp_strategy, int ngrps,
/* convert to absolute exps and expand groups */ /* convert to absolute exps and expand groups */
prevexp = absexp; prevexp = absexp;
for(i=0; i<ngrps*3; i++) { for(i=0; i<ngrps*3; i++) {
prevexp = av_clip(prevexp + dexp[i]-2, 0, 24); prevexp += dexp[i] - 2;
if (prevexp < 0 || prevexp > 24)
return -1;
for(j=0; j<group_size; j++) { for(j=0; j<group_size; j++) {
dexps[(i*group_size)+j] = prevexp; dexps[(i*group_size)+j] = prevexp;
} }
} }
return 0;
} }
/** /**
...@@ -989,9 +992,12 @@ static int decode_audio_block(AC3DecodeContext *s, int blk) ...@@ -989,9 +992,12 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
for (ch = !cpl_in_use; ch <= s->channels; ch++) { for (ch = !cpl_in_use; ch <= s->channels; ch++) {
if (s->exp_strategy[blk][ch] != EXP_REUSE) { if (s->exp_strategy[blk][ch] != EXP_REUSE) {
s->dexps[ch][0] = get_bits(gbc, 4) << !ch; s->dexps[ch][0] = get_bits(gbc, 4) << !ch;
decode_exponents(gbc, s->exp_strategy[blk][ch], if (decode_exponents(gbc, s->exp_strategy[blk][ch],
s->num_exp_groups[ch], s->dexps[ch][0], s->num_exp_groups[ch], s->dexps[ch][0],
&s->dexps[ch][s->start_freq[ch]+!!ch]); &s->dexps[ch][s->start_freq[ch]+!!ch])) {
av_log(s->avctx, AV_LOG_ERROR, "exponent out-of-range\n");
return -1;
}
if(ch != CPL_CH && ch != s->lfe_ch) if(ch != CPL_CH && ch != s->lfe_ch)
skip_bits(gbc, 2); /* skip gainrng */ skip_bits(gbc, 2); /* skip gainrng */
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment