h264: prevent overreads in intra PCM decoding.

Message ID 20120305143952.D112C5DEA1@aruru.libav.org
State New
Headers show

Commit Message

Janne Grunau March 5, 2012, 2:39 p.m.
Module: libav
Branch: release/0.8
Commit: cd17195d1c0e0f7385946506a5ad2510cf44471b

Author:    Ronald S. Bultje <rsbultje@gmail.com>
Committer: Reinhard Tartler <siretart@tauware.de>
Date:      Tue Feb 28 18:48:27 2012 -0800

h264: prevent overreads in intra PCM decoding.

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 |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

Patch

diff --git a/libavcodec/h264_cabac.c b/libavcodec/h264_cabac.c
index 75fb02c..2ee4bc0 100644
--- a/libavcodec/h264_cabac.c
+++ b/libavcodec/h264_cabac.c
@@ -1996,6 +1996,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);