[FFmpeg-cvslog] h264: Check for out of bounds reads in ff_h264_decode_extradata().

Laurent Aimar git at videolan.org
Sat Oct 1 21:38:48 CEST 2011


ffmpeg | branch: release/0.8 | Laurent Aimar <fenrir at videolan.org> | Sat Sep 24 16:44:14 2011 +0200| [101e38e08a0745a1b99d83d17358c6e81a464f8d] | committer: Michael Niedermayer

h264: Check for out of bounds reads in ff_h264_decode_extradata().

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
(cherry picked from commit 57764c699671b32f0c70795feafc0c6d7491f198)

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

 libavcodec/h264.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index b844c38..8d44337 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -1040,6 +1040,8 @@ int ff_h264_decode_extradata(H264Context *h)
         p += 6;
         for (i = 0; i < cnt; i++) {
             nalsize = AV_RB16(p) + 2;
+            if(nalsize > size - (p-buf))
+                return -1;
             if(decode_nal_units(h, p, nalsize) < 0) {
                 av_log(avctx, AV_LOG_ERROR, "Decoding sps %d from avcC failed\n", i);
                 return -1;
@@ -1050,6 +1052,8 @@ int ff_h264_decode_extradata(H264Context *h)
         cnt = *(p++); // Number of pps
         for (i = 0; i < cnt; i++) {
             nalsize = AV_RB16(p) + 2;
+            if(nalsize > size - (p-buf))
+                return -1;
             if (decode_nal_units(h, p, nalsize) < 0) {
                 av_log(avctx, AV_LOG_ERROR, "Decoding pps %d from avcC failed\n", i);
                 return -1;



More information about the ffmpeg-cvslog mailing list