avcodec/hevc_ps: Check that log2_ctb_size is not smaller than the bounds of all profiles
authorMichael Niedermayer <michaelni@gmx.at>
Wed, 25 Feb 2015 21:10:41 +0000 (22:10 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 25 Feb 2015 21:30:25 +0000 (22:30 +0100)
Fixes: unaligned memory access
Fixes: signal_sigsegv_3344165_576_cov_3406448105_DBLK_A_MAIN10_VIXS_2.bit

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Suggested-by: Christophe Gisquet <christophe.gisquet@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/hevc_ps.c

index 65b3268..85ce2cc 100644 (file)
@@ -1083,6 +1083,14 @@ int ff_hevc_decode_nal_sps(HEVCContext *s)
         av_log(s->avctx, AV_LOG_ERROR, "CTB size out of range: 2^%d\n", sps->log2_ctb_size);
         goto err;
     }
+    if (sps->log2_ctb_size < 4) {
+        av_log(s->avctx,
+               AV_LOG_ERROR,
+               "log2_ctb_size %d differs from the bounds of any known profile\n",
+               sps->log2_ctb_size);
+        avpriv_request_sample(s->avctx, "log2_ctb_size %d", sps->log2_ctb_size);
+        goto err;
+    }
     if (sps->max_transform_hierarchy_depth_inter > sps->log2_ctb_size - sps->log2_min_tb_size) {
         av_log(s->avctx, AV_LOG_ERROR, "max_transform_hierarchy_depth_inter out of range: %d\n",
                sps->max_transform_hierarchy_depth_inter);