[Title] fix prevent defect on lib/libcommon/fileio.c
authorSooyoung Ha <yoosah.ha@samsung.com>
Tue, 8 Jan 2013 07:41:32 +0000 (16:41 +0900)
committerSooyoung Ha <yoosah.ha@samsung.com>
Tue, 8 Jan 2013 07:41:32 +0000 (16:41 +0900)
[Desc.] add null check
[Issue] Prevent CID 33891~4

lib/libcommon/fileio.c
packaging/vmodemd-emul.spec

index 1ae36aa..98dbc2e 100644 (file)
@@ -36,6 +36,9 @@ gchar *get_simulator_path(void)
        
 #ifndef _WIN32
        simulator_path = (char *)malloc( 512);
+       if(simulator_path == NULL){
+           return NULL;
+       }
        memset(simulator_path, 0, 512);
 
        length = readlink("/proc/self/exe", simulator_path, 512);
@@ -92,16 +95,21 @@ gchar *get_skin_path(void)
 {
        gchar *path = NULL;
        path = get_path();
+       if(path == NULL){
+           return NULL;
+       }
 
        gchar *skin_path = NULL;
        skin_path = (char *)malloc( 512);
+       if(skin_path == NULL){
+           return NULL;
+       }
        memset(skin_path, 0, 512);
        strncpy(skin_path, path, 512);
 
        sprintf(skin_path, "%s%s", path, "/skins");
 
-       if (path)
-               g_free(path);
+       g_free(path);
 
        return skin_path;
 }
@@ -110,16 +118,21 @@ gchar *get_data_path(void)
 {
        gchar *path = NULL;
        path = get_path();
+       if(path == NULL){
+           return NULL;
+       }
 
        gchar *data_path = NULL;
        data_path = (char *)malloc( 512);
+       if(data_path == NULL){
+           return NULL;
+       }
        memset(data_path, 0, 512);
        strncpy(data_path, path, 512);
 
        sprintf(data_path, "%s%s", path, "/data");
 
-       if (path)
-               g_free(path);
+       g_free(path);
        
        return data_path;
 }
@@ -128,16 +141,21 @@ gchar *get_kernel_path(void)
 {
        gchar *path = NULL;
        path = get_data_path();
+       if(path == NULL){
+           return NULL;
+       }
 
        gchar *kernel_path = NULL;
        kernel_path = (char *)malloc( 512);
+       if(kernel_path == NULL){
+           return NULL;
+       }
        memset(kernel_path, 0, 512);
        strncpy(kernel_path, path, 512);
 
        sprintf(kernel_path, "%s%s", path, "/kernel-img");
 
-       if (path)
-               g_free(path);
+       g_free(path);
 
        return kernel_path;
 }
@@ -178,17 +196,22 @@ gchar *get_conf_path(void)
 
 #ifndef _WIN32 
        conf_path = (char *)malloc( 512);
+       if(conf_path == NULL){
+           return NULL;
+       }
        memset(conf_path, 0, 512);
 
        gchar *path = NULL;
        path = get_path();
+       if(path == NULL){
+           return NULL;
+       }
 
        strncpy(conf_path, path, 512);
 
        sprintf(conf_path, "%s%s", path, "/conf");
 
-       if (path)
-               g_free(path);
+       g_free(path);
 #else
        TCHAR APP_PATH[MAX_PATH];
        gchar org_conf_path[128] = {0, };
index d0d57ad..343b576 100644 (file)
@@ -1,6 +1,6 @@
 #git:slp/pkgs/v/vmodem-daemon-emulator
 Name: vmodemd-emul
-Version: 0.2.24
+Version: 0.2.25
 Release: 1
 Summary: Modem Emulator
 Group: System/ModemEmulator