[ITC][base-utils][Non-ACR]Fix heap-buffer-overflow 13/211913/1
authorDongHun Kwak <dh0128.kwak@samsung.com>
Mon, 12 Aug 2019 04:13:51 +0000 (13:13 +0900)
committerDongHun Kwak <dh0128.kwak@samsung.com>
Mon, 12 Aug 2019 04:15:29 +0000 (13:15 +0900)
Change-Id: Iaaf975b219c3bc6fb7870754301656612958ab18
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
src/itc/base-utils/ITs-base-utils-unumber.c

index ad2eabb86645f931ed867d7f21a05bf472dbc130..cb2f06b7f5601eeebc4588f74cfc5dc67d0b55e1 100755 (executable)
@@ -778,8 +778,9 @@ int ITc_i18n_unumber_parse_p(void)
     pText = (i18n_uchar*)calloc(strlen(pTextSample) + 1, sizeof(i18n_uchar));
     i18n_ustring_copy_ua(pText, pTextSample);
        int nValue = -1;
-       
-       nValue = i18n_unumber_parse(num_format, pText, 16, NULL);
+
+       int32_t len = i18n_ustring_get_length(pText);
+       nValue = i18n_unumber_parse(num_format, pText, len, NULL);
        int nRetVal = get_last_result();
        PRINT_RESULT_CLEANUP(I18N_ERROR_NONE, nRetVal, "i18n_unumber_parse", BaseUtilsGetError(nRetVal),free(pText););
        
@@ -822,8 +823,9 @@ int ITc_i18n_unumber_parse_decimal_p(void)
     pText = (i18n_uchar*)calloc(strlen(pTextSample) + 1, sizeof(i18n_uchar));
     i18n_ustring_copy_ua(pText, pTextSample);
        int nLength = -1;
-       
-       nLength = i18n_unumber_parse_decimal(num_format, pText, 16, NULL, szResult, nResultCapacity);
+
+       int32_t len = i18n_ustring_get_length(pText);
+       nLength = i18n_unumber_parse_decimal(num_format, pText, len, NULL, szResult, nResultCapacity);
        int nRetVal = get_last_result();
        PRINT_RESULT_CLEANUP(I18N_ERROR_NONE, nRetVal, "i18n_unumber_parse_decimal", BaseUtilsGetError(nRetVal),free(pText));
        CHECK_HANDLE_CLEANUP(szResult, "i18n_unumber_parse_decimal",free(pText));
@@ -864,7 +866,8 @@ int ITc_i18n_unumber_parse_double_p(void)
                                                                0x32, 0x31, 0x30, 0x2E, 0x31, 0x32, 0x33, 0 };
        int nValue = -1;
        
-       nValue = i18n_unumber_parse_double(num_format, parse_double, 16, NULL);
+       int32_t len = i18n_ustring_get_length(parse_double);
+       nValue = i18n_unumber_parse_double(num_format, parse_double, len, NULL);
        int nRetVal = get_last_result();
        PRINT_RESULT(I18N_ERROR_NONE, nRetVal, "i18n_unumber_parse_decimal", BaseUtilsGetError(nRetVal));
        
@@ -908,7 +911,8 @@ int ITc_i18n_unumber_parse_double_currency_p(void)
        int nRetVal = i18n_unumber_create(I18N_UNUMBER_CURRENCY, g_pDefaultTzid, nLength, g_pszDefaultLocale, NULL, &hNumFormat);
        PRINT_RESULT(I18N_ERROR_NONE, nRetVal, "i18n_unumber_create", BaseUtilsGetError(nRetVal));
        
-       dRet = i18n_unumber_parse_double_currency(hNumFormat,  szText, 16, NULL,  szCurrency);
+       int32_t len = i18n_ustring_get_length(szText);
+       dRet = i18n_unumber_parse_double_currency(hNumFormat,  szText, len, NULL,  szCurrency);
        nRetVal = get_last_result();
        PRINT_RESULT(I18N_ERROR_NONE, nRetVal, "i18n_unumber_parse_double_currency", BaseUtilsGetError(nRetVal));
        
@@ -949,7 +953,8 @@ int ITc_i18n_unumber_parse_int64_p(void)
     i18n_ustring_copy_ua(pText, pTextSample);
        int nValue = -1;
 
-       nValue = i18n_unumber_parse_int64(num_format, pText, 16, NULL);
+       int32_t len = i18n_ustring_get_length(pText);
+       nValue = i18n_unumber_parse_int64(num_format, pText, len, NULL);
        int nRetVal = get_last_result();
        PRINT_RESULT_CLEANUP(I18N_ERROR_NONE, nRetVal, "i18n_unumber_parse_int64", BaseUtilsGetError(nRetVal),free(pText););