diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2016-01-12 03:03:01 +0100 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2016-01-15 16:00:31 +0100 |
commit | 0e3c36518d9920aebee0cfaf6a54d81ae5180666 (patch) | |
tree | 9c6d9ab348b47cf431460d5ca6b25b31e9721734 /libavcodec/mpeg4videoenc.c | |
parent | 858f43043f74278cb8f4f9967a1177348a528ca0 (diff) | |
download | ffmpeg-0e3c36518d9920aebee0cfaf6a54d81ae5180666.tar.gz |
avcodec/mpeg4video: Check time_incr
Fixes assertion failure
Fixes out of memory access
Fixes: test_casex.ivf
Found-by: Tyson Smith <twsmith@mozilla.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 7c97946d6131b31340954a3f603b6bf92590a9a5)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/mpeg4videoenc.c')
-rw-r--r-- | libavcodec/mpeg4videoenc.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c index bca294ebd8..f565e3a4c4 100644 --- a/libavcodec/mpeg4videoenc.c +++ b/libavcodec/mpeg4videoenc.c @@ -1086,7 +1086,7 @@ static void mpeg4_encode_vol_header(MpegEncContext *s, } /* write mpeg4 VOP header */ -void ff_mpeg4_encode_picture_header(MpegEncContext *s, int picture_number) +int ff_mpeg4_encode_picture_header(MpegEncContext *s, int picture_number) { int time_incr; int time_div, time_mod; @@ -1112,6 +1112,12 @@ void ff_mpeg4_encode_picture_header(MpegEncContext *s, int picture_number) time_mod = FFUMOD(s->time, s->avctx->time_base.den); time_incr = time_div - s->last_time_base; av_assert0(time_incr >= 0); + + // This limits the frame duration to max 1 hour + if (time_incr > 3600) { + av_log(s->avctx, AV_LOG_ERROR, "time_incr %d too large\n", time_incr); + return AVERROR(EINVAL); + } while (time_incr--) put_bits(&s->pb, 1, 1); @@ -1137,6 +1143,8 @@ void ff_mpeg4_encode_picture_header(MpegEncContext *s, int picture_number) put_bits(&s->pb, 3, s->f_code); /* fcode_for */ if (s->pict_type == AV_PICTURE_TYPE_B) put_bits(&s->pb, 3, s->b_code); /* fcode_back */ + + return 0; } static av_cold void init_uni_dc_tab(void) |