h264: prevent overreads in intra PCM decoding.
authorRonald S. Bultje <rsbultje@gmail.com>
Wed, 29 Feb 2012 02:48:27 +0000 (18:48 -0800)
committerReinhard Tartler <siretart@tauware.de>
Sun, 1 Apr 2012 16:33:28 +0000 (18:33 +0200)
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
(cherry picked from commit d1604b3de96575195b219028e2c4f08b2259aa7d)

Signed-off-by: Reinhard Tartler <siretart@tauware.de>
libavcodec/h264_cabac.c

index e8c8503..ae3318d 100644 (file)
@@ -1958,6 +1958,8 @@ decode_intra_mb:
         }
 
         // The pixels are stored in the same order as levels in h->mb array.
+        if ((int) (h->cabac.bytestream_end - ptr) < mb_size)
+            return -1;
         memcpy(h->mb, ptr, mb_size); ptr+=mb_size;
 
         ff_init_cabac_decoder(&h->cabac, ptr, h->cabac.bytestream_end - ptr);