From: dyamy-lee Date: Tue, 13 Feb 2024 01:34:11 +0000 (+0900) Subject: fix build error about snprintf X-Git-Tag: accepted/tizen/unified/20240315.111155~9 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ea3138c02b0371bd25041b54c3598b6b948803f8;p=platform%2Fcore%2Fuifw%2Fvoice-control.git fix build error about snprintf The output may be truncated before the last format character. So, it checked length before using snprintf Change-Id: Iad722db28a5fd443df33988adbb4b755aa5afaa3 --- diff --git a/common/vc_info_parser.c b/common/vc_info_parser.c index 3ff0b6f..25e28ce 100644 --- a/common/vc_info_parser.c +++ b/common/vc_info_parser.c @@ -378,10 +378,12 @@ static int __is_symbolic_link(const char* path, bool* is_symbolic) char current_working_directory[PATH_MAX]; char temp_path[PATH_MAX]; if (getcwd(current_working_directory, PATH_MAX)) { - snprintf(temp_path, PATH_MAX, "%s/%s", current_working_directory, path); - if (strncmp(temp_path, real_path, strlen(temp_path) + 1) == 0) { - SLOG(LOG_DEBUG, vc_info_tag(), "[DEBUG] %s is real file, not symbolic link", path); - *is_symbolic = false; + if (strlen(current_working_directory) + strlen(path) <= PATH_MAX) { + snprintf(temp_path, PATH_MAX, "%s/%s", current_working_directory, path); + if (strncmp(temp_path, real_path, strlen(temp_path) + 1) == 0) { + SLOG(LOG_DEBUG, vc_info_tag(), "[DEBUG] %s is real file, not symbolic link", path); + *is_symbolic = false; + } } } }