atrac3: Fix crash in tonal component decoding.
authorMichael Niedermayer <michaelni@gmx.at>
Sat, 17 Dec 2011 02:18:58 +0000 (03:18 +0100)
committerJustin Ruggles <justin.ruggles@gmail.com>
Thu, 16 Feb 2012 20:18:45 +0000 (15:18 -0500)
Add a check to avoid writing past the end of the channel_unit.components[]
array.

Bug Found by: cosminamironesei
Fixes CVE-2012-0853
CC: libav-stable@libav.org
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Signed-off-by: Justin Ruggles <justin.ruggles@gmail.com>
libavcodec/atrac3.c

index fd036e7..136b16c 100644 (file)
@@ -402,6 +402,8 @@ static int decodeTonalComponents (GetBitContext *gb, tonal_component *pComponent
 
             for (k=0; k<coded_components; k++) {
                 sfIndx = get_bits(gb,6);
+                if (component_count >= 64)
+                    return AVERROR_INVALIDDATA;
                 pComponent[component_count].pos = j * 64 + (get_bits(gb,6));
                 max_coded_values = SAMPLES_PER_FRAME - pComponent[component_count].pos;
                 coded_values = coded_values_per_component + 1;