Message ID | 20161103103050.31714-1-michael@niedermayer.cc |
---|---|
State | Accepted |
Commit | cee1f4c06986941bd31cc19f4333d436394aa6f9 |
Headers | show |
On 03.11.2016 11:30, Michael Niedermayer wrote: > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> > --- > libavcodec/ac3dec.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c > index a95c204..499971a 100644 > --- a/libavcodec/ac3dec.c > +++ b/libavcodec/ac3dec.c > @@ -426,6 +426,10 @@ static int decode_exponents(AC3DecodeContext *s, > group_size = exp_strategy + (exp_strategy == EXP_D45); > for (grp = 0, i = 0; grp < ngrps; grp++) { > expacc = get_bits(gbc, 7); > + if (expacc >= 125) { 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. Maybe mention this in the commit message. > + 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][1]; > dexp[i++] = ungroup_3_in_7_bits_tab[expacc][2]; > Anyway, the change itself looks good to me. Best regards, Andreas
On Thu, Nov 03, 2016 at 09:18:57PM +0100, Andreas Cadhalpun wrote: > On 03.11.2016 11:30, Michael Niedermayer wrote: > > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> > > --- > > libavcodec/ac3dec.c | 4 ++++ > > 1 file changed, 4 insertions(+) > > > > diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c > > index a95c204..499971a 100644 > > --- a/libavcodec/ac3dec.c > > +++ b/libavcodec/ac3dec.c > > @@ -426,6 +426,10 @@ static int decode_exponents(AC3DecodeContext *s, > > group_size = exp_strategy + (exp_strategy == EXP_D45); > > for (grp = 0, i = 0; grp < ngrps; grp++) { > > expacc = get_bits(gbc, 7); > > + if (expacc >= 125) { > > 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. > > Maybe mention this in the commit message. added, applied thx [...]
On 11/3/16, Michael Niedermayer <michael@niedermayer.cc> wrote: > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> > --- > libavcodec/ac3dec.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c > index a95c204..499971a 100644 > --- a/libavcodec/ac3dec.c > +++ b/libavcodec/ac3dec.c > @@ -426,6 +426,10 @@ static int decode_exponents(AC3DecodeContext *s, > group_size = exp_strategy + (exp_strategy == EXP_D45); > for (grp = 0, i = 0; grp < ngrps; grp++) { > 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][1]; > dexp[i++] = ungroup_3_in_7_bits_tab[expacc][2]; > -- Please revert this ASAP. It breaks decoding valid files.
On Thu, Mar 03, 2022 at 06:36:29PM +0100, Paul B Mahol wrote: > On 11/3/16, Michael Niedermayer <michael@niedermayer.cc> wrote: > > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> > > --- > > libavcodec/ac3dec.c | 4 ++++ > > 1 file changed, 4 insertions(+) > > > > diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c > > index a95c204..499971a 100644 > > --- a/libavcodec/ac3dec.c > > +++ b/libavcodec/ac3dec.c > > @@ -426,6 +426,10 @@ static int decode_exponents(AC3DecodeContext *s, > > group_size = exp_strategy + (exp_strategy == EXP_D45); > > for (grp = 0, i = 0; grp < ngrps; grp++) { > > 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][1]; > > dexp[i++] = ungroup_3_in_7_bits_tab[expacc][2]; > > -- > > Please revert this ASAP. It breaks decoding valid files. please provide an affected file / link to one thx [...]
diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c index a95c204..499971a 100644 --- a/libavcodec/ac3dec.c +++ b/libavcodec/ac3dec.c @@ -426,6 +426,10 @@ static int decode_exponents(AC3DecodeContext *s, group_size = exp_strategy + (exp_strategy == EXP_D45); for (grp = 0, i = 0; grp < ngrps; grp++) { 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][1]; dexp[i++] = ungroup_3_in_7_bits_tab[expacc][2];
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> --- libavcodec/ac3dec.c | 4 ++++ 1 file changed, 4 insertions(+)