From: Jaehyun Kim Date: Tue, 4 Feb 2025 10:55:46 +0000 (+0900) Subject: Fix NULL pointer dereference X-Git-Tag: accepted/tizen/unified/20250206.153717~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7a06f1ce213a87c2ed54c558c4ccea657acc84e5;p=platform%2Fcore%2Fconnectivity%2Fnet-config.git Fix NULL pointer dereference Change-Id: Ib79fdfc21d1a488013cd7126d49930029562d043 Signed-off-by: Jaehyun Kim --- diff --git a/plugin/online-monitor/report-manager.c b/plugin/online-monitor/report-manager.c index dd0a224..580ad04 100755 --- a/plugin/online-monitor/report-manager.c +++ b/plugin/online-monitor/report-manager.c @@ -80,6 +80,9 @@ static inline void report_manager_make_backup(const char *file_path) backup = g_strdup_printf("%s.%d", file_path, rev); + if (!backup) + return; + if (access(backup, F_OK) == 0) report_manager_update_file_revision(rev, file_path); diff --git a/src/utils/log.c b/src/utils/log.c index a93c677..6ab9144 100755 --- a/src/utils/log.c +++ b/src/utils/log.c @@ -64,6 +64,8 @@ static inline void __netconfig_log_make_backup(void) char *backup = NULL; backup = g_strdup_printf("%s.%d", LOG_FILE_PATH, rev); + if (!backup) + return; if (access(backup, F_OK) == 0) __netconfig_log_update_file_revision(rev); diff --git a/src/utils/util.c b/src/utils/util.c index 7eddea2..5c7885e 100755 --- a/src/utils/util.c +++ b/src/utils/util.c @@ -1811,6 +1811,9 @@ char * get_least_recently_profile(const char *path) struct stat attr; gchar *full_path = g_strdup_printf("%s/%s", path, dir->d_name); + if (!full_path) + continue; + if (stat(full_path, &attr)== 0) { if(lastModified > attr.st_mtime) { diff --git a/src/wifi-config.c b/src/wifi-config.c index ab74512..8405365 100755 --- a/src/wifi-config.c +++ b/src/wifi-config.c @@ -279,6 +279,11 @@ static gboolean __remove_file(const gchar *pathname, const gchar *filename) gchar *path; path = g_strdup_printf("%s/%s", pathname, filename); + if (!path) { + ERR("Failed to allocate memory"); + return ret; + } + if (g_file_test(path, G_FILE_TEST_EXISTS) == FALSE) { ret = TRUE; } else if (g_file_test(path, G_FILE_TEST_IS_REGULAR) == TRUE) { @@ -509,6 +514,12 @@ gboolean wifi_config_save_configuration(const gchar *interface_name, } dir = g_strdup_printf(CONNMAN_STORAGE "/%s", group_name); + if (!dir) { + ERR("Failed to allocate memory"); + g_free(group_name); + return FALSE; + } + if (g_file_test(dir, G_FILE_TEST_IS_DIR) == TRUE) { if (__remove_configuration(dir) != TRUE) { ERR("[%s] is existed, but cannot remove", dir);