From: Hyunjee Kim Date: Wed, 17 Jul 2019 02:03:56 +0000 (+0900) Subject: [UTC][base-utils][Non-ACR]Fix heap-buffer-overflow X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5227b182479d993c50de0902acf8719b6d9c62cc;p=test%2Ftct%2Fnative%2Fapi.git [UTC][base-utils][Non-ACR]Fix heap-buffer-overflow Change-Id: Id8de7ffe5d2606a9b3d37a5c2a3aa2ebefe7ddf8 Signed-off-by: Hyunjee Kim --- diff --git a/src/utc/base-utils/utc-capi-base-utils-unumber.c b/src/utc/base-utils/utc-capi-base-utils-unumber.c index 7b225a2ff..4dc4a3608 100755 --- a/src/utc/base-utils/utc-capi-base-utils-unumber.c +++ b/src/utc/base-utils/utc-capi-base-utils-unumber.c @@ -925,7 +925,8 @@ int utc_capi_base_utils_i18n_unumber_parse_int64_p(void) assert_eq(ret, I18N_ERROR_NONE); assert_neq(num_format, NULL); - int32_t value = i18n_unumber_parse_int64(num_format, test_variable, 16, NULL); + int32_t len = i18n_ustring_get_length(test_variable); + int32_t value = i18n_unumber_parse_int64(num_format, test_variable, len, NULL); ret = get_last_result(); assert_eq(ret, I18N_ERROR_NONE); @@ -944,7 +945,8 @@ int utc_capi_base_utils_i18n_unumber_parse_int64_p2(void) assert_eq(ret, I18N_ERROR_NONE); assert_neq(num_format, NULL); - int32_t value = i18n_unumber_parse_int64(num_format, test_variable2, 16, NULL); + int32_t len = i18n_ustring_get_length(test_variable2); + int32_t value = i18n_unumber_parse_int64(num_format, test_variable2, len, NULL); ret = get_last_result(); assert_eq(ret, I18N_ERROR_NONE); @@ -961,7 +963,8 @@ int utc_capi_base_utils_i18n_unumber_parse_int64_p2(void) */ int utc_capi_base_utils_i18n_unumber_parse_int64_n(void) { - i18n_unumber_parse_int64(NULL, test_variable, 16, NULL); + int32_t len = i18n_ustring_get_length(test_variable); + i18n_unumber_parse_int64(NULL, test_variable, len, NULL); ret = get_last_result(); assert_eq(ret, I18N_ERROR_INVALID_PARAMETER); @@ -1018,7 +1021,8 @@ int utc_capi_base_utils_i18n_unumber_parse_double_p(void) i18n_uchar parse_double[] = { '1', '2', '2', '3', '.', '1', '1', 0 }; - double value = i18n_unumber_parse_double(num_format, parse_double, 8, NULL); + int32_t len = i18n_ustring_get_length(parse_double); + double value = i18n_unumber_parse_double(num_format, parse_double, len, NULL); ret = get_last_result(); assert_eq(ret, I18N_ERROR_NONE); @@ -1039,7 +1043,8 @@ int utc_capi_base_utils_i18n_unumber_parse_double_p2(void) i18n_uchar parse_double[] = { '-', '1', '2', '2', '3', '.', '1', '1', 0 }; - double value = i18n_unumber_parse_double(num_format, parse_double, 8, NULL); + int32_t len = i18n_ustring_get_length(parse_double); + double value = i18n_unumber_parse_double(num_format, parse_double, len, NULL); ret = get_last_result(); assert_eq(ret, I18N_ERROR_NONE); @@ -1057,7 +1062,8 @@ int utc_capi_base_utils_i18n_unumber_parse_double_n(void) { i18n_uchar parse_double[] = { '1', '2', '2', '3', '.', '1', '1', 0 }; - i18n_unumber_parse_double(NULL, parse_double, 8, NULL); + int32_t len = i18n_ustring_get_length(parse_double); + i18n_unumber_parse_double(NULL, parse_double, len, NULL); ret = get_last_result(); assert_eq(ret, I18N_ERROR_INVALID_PARAMETER); @@ -1123,7 +1129,8 @@ int utc_capi_base_utils_i18n_unumber_parse_decimal_p(void) _text = (i18n_uchar*)calloc(strlen(text) + 1, sizeof(i18n_uchar)); i18n_ustring_copy_ua(_text, text); - i18n_unumber_parse_decimal(num_format, _text, 10, NULL, result, BUF_SIZE); + int32_t _text_length = i18n_ustring_get_length(_text); + i18n_unumber_parse_decimal(num_format, _text, _text_length, NULL, result, BUF_SIZE); ret = get_last_result(); free(_text); assert_eq(ret, I18N_ERROR_NONE); @@ -1149,7 +1156,8 @@ int utc_capi_base_utils_i18n_unumber_parse_decimal_p2(void) _text = (i18n_uchar*)calloc(strlen(text) + 1, sizeof(i18n_uchar)); i18n_ustring_copy_ua(_text, text); - i18n_unumber_parse_decimal(num_format, _text, 16, NULL, result, BUF_SIZE); + int32_t _text_length = i18n_ustring_get_length(_text); + i18n_unumber_parse_decimal(num_format, _text, _text_length, NULL, result, BUF_SIZE); ret = get_last_result(); free(_text); @@ -1174,7 +1182,8 @@ int utc_capi_base_utils_i18n_unumber_parse_decimal_n(void) _text = (i18n_uchar*)calloc(strlen(text) + 1, sizeof(i18n_uchar)); i18n_ustring_copy_ua(_text, text); - i18n_unumber_parse_decimal(NULL, _text, 16, NULL, result, BUF_SIZE); + int32_t _text_length = i18n_ustring_get_length(_text); + i18n_unumber_parse_decimal(NULL, _text, _text_length, NULL, result, BUF_SIZE); ret = get_last_result(); free(_text); @@ -1249,7 +1258,8 @@ int utc_capi_base_utils_i18n_unumber_parse_decimal_n4(void) _text = (i18n_uchar*)calloc(strlen(text) + 1, sizeof(i18n_uchar)); i18n_ustring_copy_ua(_text, text); - i18n_unumber_parse_decimal(num_format, _text, 16, NULL, NULL, BUF_SIZE); + int32_t _text_length = i18n_ustring_get_length(_text); + i18n_unumber_parse_decimal(num_format, _text, _text_length, NULL, NULL, BUF_SIZE); ret = get_last_result(); free(_text); @@ -1276,7 +1286,8 @@ int utc_capi_base_utils_i18n_unumber_parse_decimal_n5(void) _text = (i18n_uchar*)calloc(strlen(text) + 1, sizeof(i18n_uchar)); i18n_ustring_copy_ua(_text, text); - i18n_unumber_parse_decimal(num_format, _text, 16, NULL, result, -1); + int32_t _text_length = i18n_ustring_get_length(_text); + i18n_unumber_parse_decimal(num_format, _text, _text_length, NULL, result, -1); ret = get_last_result(); free(_text); @@ -1305,7 +1316,8 @@ int utc_capi_base_utils_i18n_unumber_parse_double_currency_p(void) assert_eq(ret, I18N_ERROR_NONE); assert_neq(num_format, NULL); - i18n_unumber_parse_double_currency(num_format, _text, 16, NULL, currency); + int32_t _text_length = i18n_ustring_get_length(_text); + i18n_unumber_parse_double_currency(num_format, _text, _text_length, NULL, currency); ret = get_last_result(); assert_eq(ret, I18N_ERROR_NONE); @@ -1332,7 +1344,8 @@ int utc_capi_base_utils_i18n_unumber_parse_double_currency_p2(void) assert_eq(ret, I18N_ERROR_NONE); assert_neq(num_format, NULL); - i18n_unumber_parse_double_currency(num_format, _text, 16, NULL, currency); + int32_t _text_length = i18n_ustring_get_length(_text); + i18n_unumber_parse_double_currency(num_format, _text, _text_length, NULL, currency); ret = get_last_result(); assert_eq(ret, I18N_ERROR_NONE); @@ -1350,7 +1363,8 @@ int utc_capi_base_utils_i18n_unumber_parse_double_currency_n(void) i18n_uchar currency[BUF_SIZE] = { 0, }; i18n_uchar _text[] = { 0x0024, 0x0031, 0x0032, 0x002E, 0x0030, 0x0030, 0 }; - i18n_unumber_parse_double_currency(NULL, _text, 16, NULL, currency); + int32_t _text_length = i18n_ustring_get_length(_text); + i18n_unumber_parse_double_currency(NULL, _text, _text_length, NULL, currency); ret = get_last_result(); assert_eq(ret, I18N_ERROR_INVALID_PARAMETER); @@ -1431,7 +1445,8 @@ int utc_capi_base_utils_i18n_unumber_parse_double_currency_n4(void) assert_eq(ret, I18N_ERROR_NONE); assert_neq(num_format, NULL); - i18n_unumber_parse_double_currency(num_format, _text, 16, NULL, NULL); + int32_t _text_length = i18n_ustring_get_length(_text); + i18n_unumber_parse_double_currency(num_format, _text, _text_length, NULL, NULL); ret = get_last_result(); assert_eq(ret, I18N_ERROR_INVALID_PARAMETER);