From f8f420256bfa4a589472536c09c867bd64847fb6 Mon Sep 17 00:00:00 2001 From: Kalev Lember Date: Wed, 11 Sep 2013 16:12:49 +0200 Subject: network: Fix a possible crash with no active connections As a precaution, check the return value of get_active_connections to avoid dereferencing a NULL pointer. https://bugzilla.redhat.com/show_bug.cgi?id=990196 https://bugzilla.gnome.org/show_bug.cgi?id=707906 --- panels/network/net-device-mobile.c | 2 +- panels/network/net-device-simple.c | 2 +- panels/network/net-device-wifi.c | 2 +- panels/network/net-vpn.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/panels/network/net-device-mobile.c b/panels/network/net-device-mobile.c index aafdc79e7..8e59cc9dd 100644 --- a/panels/network/net-device-mobile.c +++ b/panels/network/net-device-mobile.c @@ -469,7 +469,7 @@ device_off_toggled (GtkSwitch *sw, path = nm_connection_get_path (connection); client = net_object_get_client (NET_OBJECT (device_mobile)); acs = nm_client_get_active_connections (client); - for (i = 0; i < acs->len; i++) { + for (i = 0; acs && i < acs->len; i++) { a = (NMActiveConnection*)acs->pdata[i]; if (strcmp (nm_active_connection_get_connection (a), path) == 0) { nm_client_deactivate_connection (client, a); diff --git a/panels/network/net-device-simple.c b/panels/network/net-device-simple.c index 0b936edb8..4be2fcaae 100644 --- a/panels/network/net-device-simple.c +++ b/panels/network/net-device-simple.c @@ -178,7 +178,7 @@ device_off_toggled (GtkSwitch *sw, path = nm_connection_get_path (connection); client = net_object_get_client (NET_OBJECT (device_simple)); acs = nm_client_get_active_connections (client); - for (i = 0; i < acs->len; i++) { + for (i = 0; acs && i < acs->len; i++) { a = (NMActiveConnection*)acs->pdata[i]; if (strcmp (nm_active_connection_get_connection (a), path) == 0) { nm_client_deactivate_connection (client, a); diff --git a/panels/network/net-device-wifi.c b/panels/network/net-device-wifi.c index efb3796e8..397d5565f 100644 --- a/panels/network/net-device-wifi.c +++ b/panels/network/net-device-wifi.c @@ -1147,7 +1147,7 @@ stop_shared_connection (NetDeviceWifi *device_wifi) device = net_device_get_nm_device (NET_DEVICE (device_wifi)); client = net_object_get_client (NET_OBJECT (device_wifi)); connections = nm_client_get_active_connections (client); - for (i = 0; i < connections->len; i++) { + for (i = 0; connections && i < connections->len; i++) { c = (NMActiveConnection *)connections->pdata[i]; devices = nm_active_connection_get_devices (c); diff --git a/panels/network/net-vpn.c b/panels/network/net-vpn.c index 9125aa636..35c0f2230 100644 --- a/panels/network/net-vpn.c +++ b/panels/network/net-vpn.c @@ -390,7 +390,7 @@ device_off_toggled (GtkSwitch *sw, path = nm_connection_get_path (vpn->priv->connection); client = net_object_get_client (NET_OBJECT (vpn)); acs = nm_client_get_active_connections (client); - for (i = 0; i < acs->len; i++) { + for (i = 0; acs && i < acs->len; i++) { a = (NMActiveConnection*)acs->pdata[i]; if (strcmp (nm_active_connection_get_connection (a), path) == 0) { nm_client_deactivate_connection (client, a); -- cgit v1.2.1