From: Ji-hoon Lee Date: Tue, 19 Mar 2024 11:42:44 +0000 (+0900) Subject: Add a return value check routine X-Git-Tag: accepted/tizen/unified/20240325.141227^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f4dfcd7641a91b7d02e1dd01613ce6095c4c837f;p=platform%2Fcore%2Fuifw%2Fvoice-control.git Add a return value check routine Change-Id: I8dbf71575f71e18fbfa2417c58d67ad4c73fe6e0 --- diff --git a/common/vc_info_parser.c b/common/vc_info_parser.c index 3eb3081..e07601d 100644 --- a/common/vc_info_parser.c +++ b/common/vc_info_parser.c @@ -375,12 +375,15 @@ static int __is_symbolic_link(const char* path, bool* is_symbolic) SLOG(LOG_DEBUG, vc_info_tag(), "[DEBUG] %s is real file, not symbolic link", path); *is_symbolic = false; } else { - char current_working_directory[PATH_MAX]; - char temp_path[PATH_MAX*2]; + char current_working_directory[PATH_MAX + 1] = {'\0', }; + char temp_path[PATH_MAX + 1] = {'\0', }; if (getcwd(current_working_directory, PATH_MAX)) { - if (strlen(current_working_directory) + strlen(path) <= PATH_MAX*2) { - snprintf(temp_path, PATH_MAX*2, "%s/%s", current_working_directory, path); - if (strncmp(temp_path, real_path, strlen(temp_path) + 1) == 0) { + if (strlen(current_working_directory) + strlen(path) < PATH_MAX) { + int ret = snprintf(temp_path, PATH_MAX, "%s/%s", current_working_directory, path); + if (ret < 0) { + SLOG(LOG_ERROR, vc_info_tag(), "[ERROR] Error occurred while concatenating paths : %s %s", + current_working_directory, path); + } else 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; }