Fix overflow at i18ninfo class 67/253367/1 accepted/tizen/unified/20210210.052209 submit/tizen/20210209.074558 submit/tizen/20210209.075303
authorJinWang An <jinwang.an@samsung.com>
Tue, 9 Feb 2021 07:39:50 +0000 (16:39 +0900)
committerJinWang An <jinwang.an@samsung.com>
Tue, 9 Feb 2021 07:39:50 +0000 (16:39 +0900)
Change-Id: I78c77ea9a6e93abaa408599650b652ee59fef31c
Signed-off-by: JinWang An <jinwang.an@samsung.com>
i18ninfo/i18ninfo.cpp

index 4c25567..4c7df5a 100644 (file)
@@ -354,9 +354,9 @@ static char *_date_basic_format_convert(const char *input_pattern, int i, const
        int ret = 0;
        i18n_udate_format_h format_h = NULL;
        i18n_uchar timezone[BUF_SIZE] = {0, };
-       i18n_ustring_copy_ua_n(timezone, default_locale, BUF_SIZE);
+       i18n_ustring_copy_ua_n(timezone, default_locale, BUF_SIZE - 1);
        i18n_uchar pattern[BUF_SIZE] = {0, };
-       i18n_ustring_copy_ua_n(pattern, input_pattern, BUF_SIZE);
+       i18n_ustring_copy_ua_n(pattern, input_pattern, BUF_SIZE - 1);
        ret = i18n_udate_create(I18N_UDATE_PATTERN, I18N_UDATE_PATTERN, default_locale, timezone,  -1, pattern, -1, &format_h);
        CHECK_ERROR("i18n_udate_create", ret);
 
@@ -542,7 +542,7 @@ static int __get_date_and_time(char *input_time)
        CHECK_ERROR("i18n_udatepg_create", ret);
 
        i18n_uchar format[BUF_SIZE] = {0, };
-       i18n_ustring_copy_ua_n(format, "ddMMMyyyyHHmmssz", BUF_SIZE);
+       i18n_ustring_copy_ua_n(format, "ddMMMyyyyHHmmssz", BUF_SIZE - 1);
 
        /* To get default time zone id */
        i18n_timezone_h tmz;
@@ -1005,7 +1005,7 @@ static int __get_timezone_info(char *timezone_id)
        CHECK_ERROR("i18n_udatepg_create", ret);
 
        i18n_uchar format[BUF_SIZE] = {0, };
-       i18n_ustring_copy_ua_n(format, "ddMMMyyyyHHmmssz", BUF_SIZE);
+       i18n_ustring_copy_ua_n(format, "ddMMMyyyyHHmmssz", BUF_SIZE - 1);
 
        int pattern_len = 0, len = 0;
        i18n_uchar pattern[BUF_SIZE] = {0, }, skeleton[BUF_SIZE] = {0, };
@@ -1283,7 +1283,7 @@ static int __convert_number(char *custom_number)
                if (NULL == number_to_convert)
                        return I18N_ERROR_OUT_OF_MEMORY;
 
-               i18n_ustring_copy_ua_n(number_to_convert, input_number, BUF_SIZE);
+               i18n_ustring_copy_ua_n(number_to_convert, input_number, BUF_SIZE - 1);
 
                i18n_uchar *str = _convert_unicode_numeric_values(number_to_convert, i18n_ustring_get_length(number_to_convert));
                if (NULL == str) {
@@ -1498,11 +1498,11 @@ static int __show_measure_unit(char *input_number)
                const int width = 100;
                const char *input = " ";
                i18n_uchar dest_narrow[width];
-               i18n_ustring_copy_ua_n(dest_narrow, input, width);
+               i18n_ustring_copy_ua_n(dest_narrow, input, width - 1);
                i18n_uchar dest_short[width];
-               i18n_ustring_copy_ua_n(dest_short, input, width);
+               i18n_ustring_copy_ua_n(dest_short, input, width - 1);
                i18n_uchar dest_wide[width];
-               i18n_ustring_copy_ua_n(dest_wide, input, width);
+               i18n_ustring_copy_ua_n(dest_wide, input, width - 1);
 
                int32_t length = 0;
                error_code = i18n_measure_format_format_measures(measure_format_narrow, measure_array, measure_array_count,