Fix NULL pointer dereference 24/319124/1
authorJaehyun Kim <jeik01.kim@samsung.com>
Tue, 4 Feb 2025 10:55:46 +0000 (19:55 +0900)
committerJaehyun Kim <jeik01.kim@samsung.com>
Tue, 4 Feb 2025 10:55:46 +0000 (19:55 +0900)
Change-Id: Ib79fdfc21d1a488013cd7126d49930029562d043
Signed-off-by: Jaehyun Kim <jeik01.kim@samsung.com>
plugin/online-monitor/report-manager.c
src/utils/log.c
src/utils/util.c
src/wifi-config.c

index dd0a2240bc9a468a39b9e0f052b9ecae2d395180..580ad04af26a70c64e37661bd6e0ce09d811a837 100755 (executable)
@@ -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);
 
index a93c677cd11a6a898091af9feed42bc40e193f29..6ab9144df481e8f0ac961deb49dec653ce251e5d 100755 (executable)
@@ -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);
index 7eddea2a29b03072d356c33c024a8f52cc1c631d..5c7885ee5664997cebb52956626100bb2cc8e053 100755 (executable)
@@ -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)
                                {
index ab74512c052d3cff2e185e6edd8c669686b2fa41..84053659363a9c6d61ea4d983cfdd8725d61b4cc 100755 (executable)
@@ -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);