cli: prevent possible crash if removing devices while nmcli running (bgo #693158)
This commit is contained in:
@@ -531,9 +531,12 @@ fill_in_fields_con_status (NMActiveConnection *active, GSList *con_list)
|
|||||||
devices = nm_active_connection_get_devices (active);
|
devices = nm_active_connection_get_devices (active);
|
||||||
for (i = 0; devices && (i < devices->len); i++) {
|
for (i = 0; devices && (i < devices->len); i++) {
|
||||||
NMDevice *device = g_ptr_array_index (devices, 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));
|
if (dev_iface) {
|
||||||
g_string_append_c (dev_str, ',');
|
g_string_append (dev_str, dev_iface);
|
||||||
|
g_string_append_c (dev_str, ',');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (dev_str->len > 0)
|
if (dev_str->len > 0)
|
||||||
g_string_truncate (dev_str, dev_str->len - 1); /* Cut off last ',' */
|
g_string_truncate (dev_str, dev_str->len - 1); /* Cut off last ',' */
|
||||||
@@ -1087,7 +1090,7 @@ find_device_for_connection (NmCli *nmc,
|
|||||||
|
|
||||||
if (iface) {
|
if (iface) {
|
||||||
const char *dev_iface = nm_device_get_iface (dev);
|
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)) {
|
&& nm_device_connection_compatible (dev, connection, NULL)) {
|
||||||
found_device = dev;
|
found_device = dev;
|
||||||
}
|
}
|
||||||
|
@@ -833,8 +833,10 @@ show_device_info (gpointer data, gpointer user_data)
|
|||||||
NMDevice *slave = g_ptr_array_index (slaves, idx);
|
NMDevice *slave = g_ptr_array_index (slaves, idx);
|
||||||
const char *iface = nm_device_get_iface (slave);
|
const char *iface = nm_device_get_iface (slave);
|
||||||
|
|
||||||
g_string_append (bond_slaves_str, iface);
|
if (iface) {
|
||||||
g_string_append_c (bond_slaves_str, ' ');
|
g_string_append (bond_slaves_str, iface);
|
||||||
|
g_string_append_c (bond_slaves_str, ' ');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (bond_slaves_str->len > 0)
|
if (bond_slaves_str->len > 0)
|
||||||
g_string_truncate (bond_slaves_str, bond_slaves_str->len-1); /* Chop off last space */
|
g_string_truncate (bond_slaves_str, bond_slaves_str->len-1); /* Chop off last space */
|
||||||
@@ -1018,7 +1020,7 @@ do_devices_list (NmCli *nmc, int argc, char **argv)
|
|||||||
NMDevice *candidate = g_ptr_array_index (devices, i);
|
NMDevice *candidate = g_ptr_array_index (devices, i);
|
||||||
const char *dev_iface = nm_device_get_iface (candidate);
|
const char *dev_iface = nm_device_get_iface (candidate);
|
||||||
|
|
||||||
if (!strcmp (dev_iface, iface))
|
if (!g_strcmp0 (dev_iface, iface))
|
||||||
device = candidate;
|
device = candidate;
|
||||||
}
|
}
|
||||||
if (!device) {
|
if (!device) {
|
||||||
@@ -1182,7 +1184,7 @@ do_device_disconnect (NmCli *nmc, int argc, char **argv)
|
|||||||
NMDevice *candidate = g_ptr_array_index (devices, i);
|
NMDevice *candidate = g_ptr_array_index (devices, i);
|
||||||
const char *dev_iface = nm_device_get_iface (candidate);
|
const char *dev_iface = nm_device_get_iface (candidate);
|
||||||
|
|
||||||
if (!strcmp (dev_iface, iface))
|
if (!g_strcmp0 (dev_iface, iface))
|
||||||
device = candidate;
|
device = candidate;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1321,7 +1323,7 @@ do_device_wifi_list (NmCli *nmc, int argc, char **argv)
|
|||||||
NMDevice *candidate = g_ptr_array_index (devices, i);
|
NMDevice *candidate = g_ptr_array_index (devices, i);
|
||||||
const char *dev_iface = nm_device_get_iface (candidate);
|
const char *dev_iface = nm_device_get_iface (candidate);
|
||||||
|
|
||||||
if (!strcmp (dev_iface, iface)) {
|
if (!g_strcmp0 (dev_iface, iface)) {
|
||||||
device = candidate;
|
device = candidate;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1517,7 +1519,7 @@ find_wifi_device_by_iface (const GPtrArray *devices, const char *iface, int *idx
|
|||||||
|
|
||||||
if (iface) {
|
if (iface) {
|
||||||
/* If a iface was specified then use it. */
|
/* If a iface was specified then use it. */
|
||||||
if (strcmp (dev_iface, iface) == 0) {
|
if (g_strcmp0 (dev_iface, iface) == 0) {
|
||||||
device = candidate;
|
device = candidate;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1968,7 +1970,7 @@ do_device_wimax_list (NmCli *nmc, int argc, char **argv)
|
|||||||
NMDevice *candidate = g_ptr_array_index (devices, i);
|
NMDevice *candidate = g_ptr_array_index (devices, i);
|
||||||
const char *dev_iface = nm_device_get_iface (candidate);
|
const char *dev_iface = nm_device_get_iface (candidate);
|
||||||
|
|
||||||
if (!strcmp (dev_iface, iface)) {
|
if (!g_strcmp0 (dev_iface, iface)) {
|
||||||
device = candidate;
|
device = candidate;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user