[FFmpeg-cvslog] h264: Check gray scale CBP, fix out of array accesses.

Michael Niedermayer git at videolan.org
Mon Nov 19 00:39:56 CET 2012


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Sun Nov 18 21:36:06 2012 +0100| [8a03a60b4af46c001d5686b9303f48f6c4ebdf6c] | committer: Michael Niedermayer

h264: Check gray scale CBP, fix out of array accesses.

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8a03a60b4af46c001d5686b9303f48f6c4ebdf6c
---

 libavcodec/h264_cabac.c |    5 +++++
 libavcodec/h264_cavlc.c |    5 +++++
 2 files changed, 10 insertions(+)

diff --git a/libavcodec/h264_cabac.c b/libavcodec/h264_cabac.c
index a37094b..76a6481 100644
--- a/libavcodec/h264_cabac.c
+++ b/libavcodec/h264_cabac.c
@@ -2266,6 +2266,11 @@ decode_intra_mb:
         cbp  = decode_cabac_mb_cbp_luma( h );
         if(decode_chroma)
             cbp |= decode_cabac_mb_cbp_chroma( h ) << 4;
+    } else {
+        if (!decode_chroma && cbp>15) {
+            av_log(s->avctx, AV_LOG_ERROR, "gray chroma\n");
+            return AVERROR_INVALIDDATA;
+        }
     }
 
     h->cbp_table[mb_xy] = h->cbp = cbp;
diff --git a/libavcodec/h264_cavlc.c b/libavcodec/h264_cavlc.c
index 6dfe247..cd1130a 100644
--- a/libavcodec/h264_cavlc.c
+++ b/libavcodec/h264_cavlc.c
@@ -1070,6 +1070,11 @@ decode_intra_mb:
             if(IS_INTRA4x4(mb_type)) cbp= golomb_to_intra4x4_cbp_gray[cbp];
             else                     cbp= golomb_to_inter_cbp_gray[cbp];
         }
+    } else {
+        if (!decode_chroma && cbp>15) {
+            av_log(s->avctx, AV_LOG_ERROR, "gray chroma\n");
+            return AVERROR_INVALIDDATA;
+        }
     }
 
     if(dct8x8_allowed && (cbp&15) && !IS_INTRA(mb_type)){



More information about the ffmpeg-cvslog mailing list