[security] replaced sprintf & g_sprintf with snprintf & g_snprintf 28/140428/3
authorSangdok Mo <sd.mo@samsung.com>
Tue, 25 Jul 2017 03:16:34 +0000 (12:16 +0900)
committerSangdok Mo <sd.mo@samsung.com>
Tue, 25 Jul 2017 23:48:23 +0000 (08:48 +0900)
put a null-check into right position

Change-Id: I25296b9d9d5cad493e9405d659205cf395364366
Signed-off-by: Sangdok Mo <sd.mo@samsung.com>
src/api/maps_view_snapshot.cpp
src/plugin/module.cpp

index 8007247..3c6e6d1 100644 (file)
@@ -200,9 +200,9 @@ static int __build_tmp_path(const char *path, char **tmp_path)
 
        int retry = 0;
        const int retry_max = 20;
-       sprintf(*tmp_path, "%s.tmp", path);
+       snprintf(*tmp_path, tmp_path_len + 10, "%s.tmp", path);
        while(access(*tmp_path, F_OK) != -1 && ++retry < retry_max) {
-               sprintf(*tmp_path, "%s.tmp%d", path, retry);
+               snprintf(*tmp_path, tmp_path_len + 10, "%s.tmp%d", path, retry);
        }
        if (retry >= retry_max) {
                MAPS_LOGD("There are already too many temporary files.");
index e44ff76..0032831 100644 (file)
@@ -422,7 +422,6 @@ plugin::GMod *plugin::binary_extractor::gmod_new(const string &module_file,
        }
 
        gmod->path = g_strnfill(100, 0);
-       g_sprintf(gmod->path, "%s/%s", MAPS_PLUGINS_PATH_PREFIX, gmod->name);
        if (!gmod->path) {
                //LCOV_EXCL_START
                g_free(gmod->name);
@@ -430,6 +429,7 @@ plugin::GMod *plugin::binary_extractor::gmod_new(const string &module_file,
                return NULL;
                //LCOV_EXCL_STOP
        }
+       g_snprintf(gmod->path, 100, "%s/%s", MAPS_PLUGINS_PATH_PREFIX, gmod->name);
 
        gmod->module = g_module_open(gmod->path, G_MODULE_BIND_LAZY);
        if (!gmod->module) {