From c23e1bbb4498cb5927a5386c712f15d53dda342b Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 7 Nov 2013 00:38:20 -0600 Subject: [PATCH] ifcfg-rh: don't crash when in-memory-only connections don't have paths If the connection has never been saved to disk, it won't have a path yet, but that doesn't mean we should crash. Next, when reloading connections, only try to do connection matching on connections that have paths, otherwise all in-memory-only connections would be removed at the end of read_connections(). --- src/settings/plugins/ifcfg-rh/plugin.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/settings/plugins/ifcfg-rh/plugin.c b/src/settings/plugins/ifcfg-rh/plugin.c index c51afbee39..ea0ddf34e2 100644 --- a/src/settings/plugins/ifcfg-rh/plugin.c +++ b/src/settings/plugins/ifcfg-rh/plugin.c @@ -212,7 +212,7 @@ find_by_path (SCPluginIfcfg *self, const char *path) g_hash_table_iter_init (&iter, priv->connections); while (g_hash_table_iter_next (&iter, NULL, (gpointer) &candidate)) { - if (g_str_equal (path, nm_ifcfg_connection_get_path (candidate))) + if (g_strcmp0 (path, nm_ifcfg_connection_get_path (candidate)) == 0) return candidate; } return NULL; @@ -445,8 +445,11 @@ read_connections (SCPluginIfcfg *plugin) oldconns = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); g_hash_table_iter_init (&iter, priv->connections); - while (g_hash_table_iter_next (&iter, NULL, &value)) - g_hash_table_insert (oldconns, g_strdup (nm_ifcfg_connection_get_path (value)), value); + while (g_hash_table_iter_next (&iter, NULL, &value)) { + const char *ifcfg_path = nm_ifcfg_connection_get_path (value); + if (ifcfg_path) + g_hash_table_insert (oldconns, g_strdup (ifcfg_path), value); + } while ((item = g_dir_read_name (dir))) { char *full_path, *old_path;