Commit cee1f4c0 authored by Michael Niedermayer's avatar Michael Niedermayer

avcodec/ac3dec: Check expacc

this is somewhat a magic number, which can be understood from reading section
"7.1.2 Exponent Strategy" of the ac3 specification, in short:
Three exponents each represented as number 0-4 are grouped together and
base-5 encoded, so the maximal correct value is 25*4 + 5*4 + 4 = 124.
Reviewed-by: 's avatarAndreas Cadhalpun <andreas.cadhalpun@googlemail.com>
Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent 0bd1be65
...@@ -426,6 +426,10 @@ static int decode_exponents(AC3DecodeContext *s, ...@@ -426,6 +426,10 @@ static int decode_exponents(AC3DecodeContext *s,
group_size = exp_strategy + (exp_strategy == EXP_D45); group_size = exp_strategy + (exp_strategy == EXP_D45);
for (grp = 0, i = 0; grp < ngrps; grp++) { for (grp = 0, i = 0; grp < ngrps; grp++) {
expacc = get_bits(gbc, 7); expacc = get_bits(gbc, 7);
if (expacc >= 125) {
av_log(s->avctx, AV_LOG_ERROR, "expacc %d is out-of-range\n", expacc);
return AVERROR_INVALIDDATA;
}
dexp[i++] = ungroup_3_in_7_bits_tab[expacc][0]; dexp[i++] = ungroup_3_in_7_bits_tab[expacc][0];
dexp[i++] = ungroup_3_in_7_bits_tab[expacc][1]; dexp[i++] = ungroup_3_in_7_bits_tab[expacc][1];
dexp[i++] = ungroup_3_in_7_bits_tab[expacc][2]; dexp[i++] = ungroup_3_in_7_bits_tab[expacc][2];
......
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