From 3d320d8ce3ad8d4ddbd8ad9460eafb1c370d833b Mon Sep 17 00:00:00 2001 From: "jinwang.an" Date: Mon, 29 Jul 2019 16:52:30 +0900 Subject: [PATCH] Change from strcat to strncat Change-Id: I0ebd813dffa692a36636cabc69fe9d4362a24232 Signed-off-by: jinwang.an Signed-off-by: DongHun Kwak --- i18ninfo/i18ninfo.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/i18ninfo/i18ninfo.cpp b/i18ninfo/i18ninfo.cpp index 603aca8..5e032d0 100644 --- a/i18ninfo/i18ninfo.cpp +++ b/i18ninfo/i18ninfo.cpp @@ -475,14 +475,19 @@ i18n_udate _time_convert(char *input_time) { i18n_ucalendar_h ucal; i18n_udate date; + char buf[BUF_SIZE] = {0, }; int ret = I18N_ERROR_NONE; int year, month, day, hour, minute, second; struct tm result; - if (strlen(input_time) < 9) { - strcat(input_time, "000000"); + if (input_time) { + strncpy(buf, input_time, sizeof(buf)-1); } - strptime(input_time, "%Y%m%d%H%M%S", &result); + + if (strlen(buf) < 9) { + strncat(buf, "000000", 6); + } + strptime(buf, "%Y%m%d%H%M%S", &result); if (result.tm_year >= 100) result.tm_year = result.tm_year % 100 + 2000; -- 2.7.4