diff options
author | Andreas Cadhalpun <andreas.cadhalpun@googlemail.com> | 2015-04-16 21:25:26 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-06-10 02:13:10 +0200 |
commit | 997a997465b5848bfa8437345fef67c81ccfd387 (patch) | |
tree | 51519e1a030a24bfe998081a4d63d370ccba6a8c | |
parent | c962405c1968c0bfb3271f225df3ccabcb683c0e (diff) | |
download | ffmpeg-997a997465b5848bfa8437345fef67c81ccfd387.tar.gz |
ac3: validate end in ff_ac3_bit_alloc_calc_mask
This fixes an invalid read if end is 0:
band_end = ff_ac3_bin_to_band_tab[end-1] + 1;
Depending on what is before the array, this can cause stack smashing,
when band_end becomes too large.
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit bc4fee7f2a51635fa3c0f61d1e5164da1efeded3)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavcodec/ac3.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/libavcodec/ac3.c b/libavcodec/ac3.c index 29e132f5d1..8d39bbe83b 100644 --- a/libavcodec/ac3.c +++ b/libavcodec/ac3.c @@ -131,6 +131,9 @@ int ff_ac3_bit_alloc_calc_mask(AC3BitAllocParameters *s, int16_t *band_psd, int band_start, band_end, begin, end1; int lowcomp, fastleak, slowleak; + if (end <= 0) + return AVERROR_INVALIDDATA; + /* excitation function */ band_start = ff_ac3_bin_to_band_tab[start]; band_end = ff_ac3_bin_to_band_tab[end-1] + 1; |