summaryrefslogtreecommitdiff
path: root/libavcodec/h264.c
diff options
context:
space:
mode:
authorLaurent Aimar <fenrir@videolan.org>2011-09-24 16:16:39 +0200
committerReinhard Tartler <siretart@tauware.de>2012-02-19 15:08:42 +0100
commitec2a1d91e216c30a1e286b2141eaabe64a0296f5 (patch)
tree2f676648eeb1ca901db343fa333e88668d0602b9 /libavcodec/h264.c
parent958e0f705dab60f4d11ab90e2ebe2b4e7393fb41 (diff)
downloadffmpeg-ec2a1d91e216c30a1e286b2141eaabe64a0296f5.tar.gz
h264: check for out of bounds reads in ff_h264_decode_extradata().
Signed-off-by: Anton Khirnov <anton@khirnov.net> (cherry picked from commit d1186ff72d75b6067770890758c4feb92abd84f7) Signed-off-by: Anton Khirnov <anton@khirnov.net>
Diffstat (limited to 'libavcodec/h264.c')
-rw-r--r--libavcodec/h264.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 75075f6b3c..276ace280e 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -1032,6 +1032,8 @@ int ff_h264_decode_extradata(H264Context *h)
p += 6;
for (i = 0; i < cnt; i++) {
nalsize = AV_RB16(p) + 2;
+ if (p - avctx->extradata + nalsize > avctx->extradata_size)
+ 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;
@@ -1042,6 +1044,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 (p - avctx->extradata + nalsize > avctx->extradata_size)
+ 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;