diff options
author | Christophe Gisquet <christophe.gisquet@gmail.com> | 2014-08-10 21:22:06 +0400 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-08-11 04:47:05 +0400 |
commit | 5ec85c9750f0770383b781acd6362a8bebbf4db6 (patch) | |
tree | e0f88a13014fd147c6c9a85c98627fe94f7290f2 /libavcodec/hevc_ps.c | |
parent | bfffce4d081c87b9fadcc0ce3fb5309cf8f266e5 (diff) |
hevc: do generic validation of bitstream
After finishing parsing VPS/SPS/PPS/slice header, check remaining bits,
and if an overconsumption occurred, report invalid data.
Liked-by: BBB
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/hevc_ps.c')
-rw-r--r-- | libavcodec/hevc_ps.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c index fe974bcbf2..163c5e4aab 100644 --- a/libavcodec/hevc_ps.c +++ b/libavcodec/hevc_ps.c @@ -452,6 +452,12 @@ int ff_hevc_decode_nal_vps(HEVCContext *s) } get_bits1(gb); /* vps_extension_flag */ + if (get_bits_left(gb) < 0) { + av_log(s->avctx, AV_LOG_ERROR, + "Overread VPS by %d bits\n", -get_bits_left(gb)); + goto err; + } + av_buffer_unref(&s->vps_list[vps_id]); s->vps_list[vps_id] = vps_buf; return 0; @@ -1050,6 +1056,12 @@ int ff_hevc_decode_nal_sps(HEVCContext *s) goto err; } + if (get_bits_left(gb) < 0) { + av_log(s->avctx, AV_LOG_ERROR, + "Overread SPS by %d bits\n", -get_bits_left(gb)); + goto err; + } + if (s->avctx->debug & FF_DEBUG_BITSTREAM) { av_log(s->avctx, AV_LOG_DEBUG, "Parsed SPS: id %d; coded wxh: %dx%d; " @@ -1473,6 +1485,12 @@ int ff_hevc_decode_nal_pps(HEVCContext *s) } } + if (get_bits_left(gb) < 0) { + av_log(s->avctx, AV_LOG_ERROR, + "Overread PPS by %d bits\n", -get_bits_left(gb)); + goto err; + } + av_buffer_unref(&s->pps_list[pps_id]); s->pps_list[pps_id] = pps_buf; |