[gnome-control-center] network: Fix a possible crash with no active connections



commit f8f420256bfa4a589472536c09c867bd64847fb6
Author: Kalev Lember <kalevlember gmail com>
Date:   Wed Sep 11 16:12:49 2013 +0200

    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 aafdc79..8e59cc9 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 0b936ed..4be2fca 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 efb3796..397d556 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 9125aa6..35c0f22 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);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]