From 5890a539f18d338710ae39039ff1dac986344eb1 Mon Sep 17 00:00:00 2001 From: WooHyun Jung Date: Thu, 2 Jul 2015 21:24:55 +0900 Subject: [PATCH] add null check for opendir Change-Id: I75a648b03f54ceb9ef25b09da96fb63ce0cb3182 --- pkgmgr_font/src/font_service_register.c | 42 ++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/pkgmgr_font/src/font_service_register.c b/pkgmgr_font/src/font_service_register.c index 4de31df..9c45c3c 100755 --- a/pkgmgr_font/src/font_service_register.c +++ b/pkgmgr_font/src/font_service_register.c @@ -758,36 +758,40 @@ int COMMON_PKGMGR_PLUGIN_UNINSTALL(const char *pkgid, const char *appid, GList * chmod (ELM_PROFILE_CFG, 0777); } - DIR *d; + DIR *d = NULL; struct dirent *e; - d = opendir (elm_profile_path); + if (elm_profile_path) + d = opendir (elm_profile_path); - while ((e = readdir (d))) + if (d) { - if (e->d_name[0] != '.' && (strstr(e->d_name, ".cfg") != 0 || strstr(e->d_name, ".CFG") != 0)) + while ((e = readdir (d))) { - char file_full_path[100]; + if (e->d_name[0] != '.' && (strstr(e->d_name, ".cfg") != 0 || strstr(e->d_name, ".CFG") != 0)) + { + char file_full_path[100]; - sprintf(file_full_path, "%s/%s", elm_profile_path, e->d_name); + sprintf(file_full_path, "%s/%s", elm_profile_path, e->d_name); - ret = chown(file_full_path, APP_OWNER_ID, APP_GROUP_ID); - if (ret < 0) - { - DEBUG_LOG("chown is failed %s", file_full_path); - chmod (file_full_path, 0777); - } + ret = chown(file_full_path, APP_OWNER_ID, APP_GROUP_ID); + if (ret < 0) + { + DEBUG_LOG("chown is failed %s", file_full_path); + chmod (file_full_path, 0777); + } - ret = lsetxattr(file_full_path, "security.SMACK64", "system::homedir", 15, 0); - if (ret < 0) - { - DEBUG_LOG("chsmack is failed %s", file_full_path); - chmod (file_full_path, 0777); + ret = lsetxattr(file_full_path, "security.SMACK64", "system::homedir", 15, 0); + if (ret < 0) + { + DEBUG_LOG("chsmack is failed %s", file_full_path); + chmod (file_full_path, 0777); + } } } - } - closedir (d); + closedir (d); + } free(default_font_name); free(elm_profile_path); -- 2.7.4