cli: prevent possible crash if removing devices while nmcli running (bgo #693158)

This commit is contained in:
Jiří Klimeš
2013-02-05 10:00:58 +01:00
parent 62bae8acb7
commit b3edc86e78
2 changed files with 15 additions and 10 deletions

View File

@@ -531,9 +531,12 @@ fill_in_fields_con_status (NMActiveConnection *active, GSList *con_list)
devices = nm_active_connection_get_devices (active);
for (i = 0; devices && (i < devices->len); i++) {
NMDevice *device = g_ptr_array_index (devices, i);
const char *dev_iface = nm_device_get_iface (device);
g_string_append (dev_str, nm_device_get_iface (device));
g_string_append_c (dev_str, ',');
if (dev_iface) {
g_string_append (dev_str, dev_iface);
g_string_append_c (dev_str, ',');
}
}
if (dev_str->len > 0)
g_string_truncate (dev_str, dev_str->len - 1); /* Cut off last ',' */
@@ -1087,7 +1090,7 @@ find_device_for_connection (NmCli *nmc,
if (iface) {
const char *dev_iface = nm_device_get_iface (dev);
if ( !strcmp (dev_iface, iface)
if ( !g_strcmp0 (dev_iface, iface)
&& nm_device_connection_compatible (dev, connection, NULL)) {
found_device = dev;
}