From 6dde7cf5abd46fba91f5720d1b5ce6149bbbd556 Mon Sep 17 00:00:00 2001 From: Sooyoung Ha Date: Tue, 8 Jan 2013 16:41:32 +0900 Subject: [PATCH] [Title] fix prevent defect on lib/libcommon/fileio.c [Desc.] add null check [Issue] Prevent CID 33891~4 --- lib/libcommon/fileio.c | 39 +++++++++++++++++++++++++++++++-------- packaging/vmodemd-emul.spec | 2 +- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/lib/libcommon/fileio.c b/lib/libcommon/fileio.c index 1ae36aa..98dbc2e 100644 --- a/lib/libcommon/fileio.c +++ b/lib/libcommon/fileio.c @@ -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, }; diff --git a/packaging/vmodemd-emul.spec b/packaging/vmodemd-emul.spec index d0d57ad..343b576 100644 --- a/packaging/vmodemd-emul.spec +++ b/packaging/vmodemd-emul.spec @@ -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 -- 2.7.4