Fix static analysis issue 81/268881/2
authorIlho Kim <ilho159.kim@samsung.com>
Tue, 4 Jan 2022 06:13:15 +0000 (15:13 +0900)
committerIlho Kim <ilho159.kim@samsung.com>
Tue, 4 Jan 2022 06:16:42 +0000 (15:16 +0900)
Change to check destination path's size of strncpy

Change-Id: Iad8a0f0fb7ca7777e663cb2f058975473fd0ee2e
Signed-off-by: Ilho Kim <ilho159.kim@samsung.com>
src/pkgcmd/delta.c

index ac572fe..aabfe01 100644 (file)
@@ -70,7 +70,7 @@ static GList *__list_directory(const char *dir_name, const char *tpk_path, GList
                if (!(file_info->d_type & DT_DIR)) {
                        snprintf(rel_path_old_tpk_file, PATH_MAX, "%s/%s", dir_name, d_name);
                        strncpy(path, rel_path_old_tpk_file + strlen(tpk_path),
-                                       strlen(rel_path_old_tpk_file));
+                                       sizeof(path) - 1);
                        file_path = strndup(path, sizeof(path));
                        list = g_list_append(list, file_path);
                        memset(path, 0, PATH_MAX);