aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Aimar <fenrir@videolan.org>2011-09-24 16:44:14 +0200
committerMichael Niedermayer <michaelni@gmx.at>2011-09-24 16:54:16 +0200
commit57764c699671b32f0c70795feafc0c6d7491f198 (patch)
tree9b923dfedf4f06fca83b5e5f24eaaf8cec1b1352
parent87f5e79732bb295765b5669eb03fc2d9676e588f (diff)
downloadffmpeg-57764c699671b32f0c70795feafc0c6d7491f198.tar.gz
h264: Check for out of bounds reads in ff_h264_decode_extradata().
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavcodec/h264.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index aeb36f2ff7..ec5a46409a 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -1013,6 +1013,8 @@ int ff_h264_decode_extradata(H264Context *h, const uint8_t *buf, int size)
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;
@@ -1023,6 +1025,8 @@ int ff_h264_decode_extradata(H264Context *h, const uint8_t *buf, int size)
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;