From 5696adb5ec093ff6e10f3460541d92cfd6ea2ee5 Mon Sep 17 00:00:00 2001 From: Martin Storsjo Date: Fri, 3 Jul 2015 13:56:20 +0300 Subject: [PATCH] Validate the u4_entropy_coding_mode field Previously, if this field wasn't set, the invalid coding mode could lead to crashes later. Change-Id: If8dd2f8d5f2fbdd6bb76772344f959df23159167 --- encoder/ih264e_api.c | 9 +++++++++ encoder/ih264e_error.h | 3 +++ 2 files changed, 12 insertions(+) diff --git a/encoder/ih264e_api.c b/encoder/ih264e_api.c index c034681..c46134d 100644 --- a/encoder/ih264e_api.c +++ b/encoder/ih264e_api.c @@ -1758,6 +1758,15 @@ static IV_STATUS_T api_check_struct_sanity(iv_obj_t *ps_handle, return IV_FAIL; } + if (ps_ip->s_ive_ip.u4_entropy_coding_mode > 1) + { + ps_op->s_ive_op.u4_error_code |= 1 + << IVE_UNSUPPORTEDPARAM; + ps_op->s_ive_op.u4_error_code |= + IH264E_INVALID_ENTROPY_CODING_MODE; + return IV_FAIL; + } + break; } diff --git a/encoder/ih264e_error.h b/encoder/ih264e_error.h index 1eba46c..5a7a560 100644 --- a/encoder/ih264e_error.h +++ b/encoder/ih264e_error.h @@ -223,6 +223,9 @@ typedef enum /**Not enough memory allocated as output buffer */ IH264E_INSUFFICIENT_OUTPUT_BUFFER = IH264E_CODEC_ERROR_START + 0x30, + /**Invalid entropy coding mode */ + IH264E_INVALID_ENTROPY_CODING_MODE = IH264E_CODEC_ERROR_START + 0x31, + /**max failure error code to ensure enum is 32 bits wide */ IH264E_FAIL = -1,