Fix static analysis issue 37/211037/3
authorIlho Kim <ilho159.kim@samsung.com>
Mon, 29 Jul 2019 07:27:38 +0000 (16:27 +0900)
committerIlho Kim <ilho159.kim@samsung.com>
Mon, 29 Jul 2019 08:05:12 +0000 (17:05 +0900)
Use strerror_r instead of strerror for thread safety

Change-Id: Icf2e750fb4a18250543355ad613db4bae14cf984
Signed-off-by: Ilho Kim <ilho159.kim@samsung.com>
src/install_preload_pkg.c
src/pkg_upgrade.c

index 2218344c22c2fca9745146511481db204c456a08..77e31e1426c4d00d702d12c020e82f7ab762877b 100644 (file)
@@ -62,6 +62,7 @@
 static void __make_preload_rw_list(GList *pkg_list)
 {
        FILE *file;
+       char err_buf[BUFSZE];
        char pkg_info[BUFSZE];
 
        if (pkg_list == NULL)
@@ -70,7 +71,7 @@ static void __make_preload_rw_list(GList *pkg_list)
        file = fopen(ALL_PRELOAD_RW_PKG_LIST, "a");
        if (file == NULL) {
                _E("can not open [%s]: %s\n", ALL_PRELOAD_RW_PKG_LIST,
-                               strerror(errno));
+                               strerror_r(errno, err_buf, sizeof(err_buf)));
                return;
        }
 
index 90781265668449bc42da2d4a0056237171fa1c32..4acf3ed6c1f730e929572a86a2cab82e4f85a8ea 100644 (file)
@@ -160,6 +160,7 @@ static void __make_preload_rw_list(GHashTable *preload_rw_table)
        }
        FILE *file = NULL;
 
+       char buf[BUF_SIZE];
        char tmp_path[BUF_SIZE];
        snprintf(tmp_path, BUF_SIZE, "%s.tmp", ALL_PRELOAD_RW_PKG_LIST);
 
@@ -167,8 +168,8 @@ static void __make_preload_rw_list(GHashTable *preload_rw_table)
 
        file = fopen(ALL_PRELOAD_RW_PKG_LIST, "w");
        if (file == NULL) {
-               _LOG("can not open [%s]: %s\n",
-                               ALL_PRELOAD_RW_PKG_LIST, strerror(errno));
+               _LOG("can not open [%s]: %s\n", ALL_PRELOAD_RW_PKG_LIST,
+                               strerror_r(errno, buf, sizeof(buf)));
                return;
        }
        g_hash_table_foreach(preload_rw_table, __iter_cb, file);
@@ -1265,12 +1266,13 @@ static int __process_rw_fota(GHashTable *preload_rw_table)
 
 static int __check_tmp_all_preload_rw_pkg_list()
 {
+       char buf[BUF_SIZE];
        char tmp_path[BUF_SIZE];
        snprintf(tmp_path, BUF_SIZE, "%s.tmp", ALL_PRELOAD_RW_PKG_LIST);
        if (access(tmp_path, F_OK) == 0) {
                if (rename(tmp_path, ALL_PRELOAD_RW_PKG_LIST)) {
                        _LOG("rename tmp all preload rw pkg list fail : %s\n",
-                                       strerror(errno));
+                                       strerror_r(errno, buf, sizeof(buf)));
                        return -1;
                }
        }