aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2015-02-25 15:51:28 +0100
committerMichael Niedermayer <michaelni@gmx.at>2015-03-21 01:52:51 +0100
commit6168fe32f1af32b5e3fa13d258aa436451b7cef6 (patch)
treefdf9a87ab535e473824d68c4771fc4a94271ead2
parent711374b62691ed42099ea9350ba6e6f9846012a2 (diff)
downloadffmpeg-6168fe32f1af32b5e3fa13d258aa436451b7cef6.tar.gz
avcodec/hevc_ps: Sanity checks for some log2_* values
log2 values which imply numeric overflow are not supported Signed-off-by: Michael Niedermayer <michaelni@gmx.at> (cherry picked from commit 205b2ba3d677330e023aac2f4bd3f624039256b9) Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavcodec/hevc_ps.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index 11e6eb6132..3309377455 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -895,11 +895,30 @@ int ff_hevc_decode_nal_sps(HEVCContext *s)
sps->log2_max_trafo_size = log2_diff_max_min_transform_block_size +
sps->log2_min_tb_size;
- if (sps->log2_min_tb_size >= sps->log2_min_cb_size) {
+ if (sps->log2_min_cb_size < 3 || sps->log2_min_cb_size > 30) {
+ av_log(s->avctx, AV_LOG_ERROR, "Invalid value %d for log2_min_cb_size", sps->log2_min_cb_size);
+ ret = AVERROR_INVALIDDATA;
+ goto err;
+ }
+
+ if (sps->log2_diff_max_min_coding_block_size > 30) {
+ av_log(s->avctx, AV_LOG_ERROR, "Invalid value %d for log2_diff_max_min_coding_block_size", sps->log2_diff_max_min_coding_block_size);
+ ret = AVERROR_INVALIDDATA;
+ goto err;
+ }
+
+ if (sps->log2_min_tb_size >= sps->log2_min_cb_size || sps->log2_min_tb_size < 2) {
av_log(s->avctx, AV_LOG_ERROR, "Invalid value for log2_min_tb_size");
ret = AVERROR_INVALIDDATA;
goto err;
}
+
+ if (log2_diff_max_min_transform_block_size < 0 || log2_diff_max_min_transform_block_size > 30) {
+ av_log(s->avctx, AV_LOG_ERROR, "Invalid value %d for log2_diff_max_min_transform_block_size", log2_diff_max_min_transform_block_size);
+ ret = AVERROR_INVALIDDATA;
+ goto err;
+ }
+
sps->max_transform_hierarchy_depth_inter = get_ue_golomb_long(gb);
sps->max_transform_hierarchy_depth_intra = get_ue_golomb_long(gb);