]> git.sesse.net Git - ffmpeg/commitdiff
Fixed overreads in TTA decoder with corrupted bistreams.
authorLaurent Aimar <fenrir@videolan.org>
Wed, 3 Mar 2010 19:31:46 +0000 (19:31 +0000)
committerLaurent Aimar <fenrir@videolan.org>
Wed, 3 Mar 2010 19:31:46 +0000 (19:31 +0000)
Originally committed as revision 22176 to svn://svn.ffmpeg.org/ffmpeg/trunk

libavcodec/tta.c

index b26724b5286116762a30a2747365fd3b9019149c..7dd4cc5059f2e780275d2760ed9698bc2f8230f1 100644 (file)
@@ -332,9 +332,14 @@ static int tta_decode_frame(AVCodecContext *avctx,
                 unary--;
             }
 
-            if (k)
+            if (get_bits_left(&s->gb) < k)
+                return -1;
+
+            if (k) {
+                if (k > MIN_CACHE_BITS)
+                    return -1;
                 value = (unary << k) + get_bits(&s->gb, k);
-            else
+            else
                 value = unary;
 
             // FIXME: copy paste from original
@@ -404,6 +409,8 @@ static int tta_decode_frame(AVCodecContext *avctx,
             }
         }
 
+        if (get_bits_left(&s->gb) < 32)
+            return -1;
         skip_bits(&s->gb, 32); // frame crc
 
         // convert to output buffer