core: workaround crash when connecting to wifi (rh #1025371)

rh #1025371 reports a crash in handle_ip_config_timeout() because
nm_device_wifi_get_activation_ap() did not return any access point.

The handling of the AP in nm-device-wifi.c should be reworked and soon
will be fixed. For now, play it safe, and try to cope with any cases
where nm_device_wifi_get_activation_ap() might return NULL.

Later, this patch should be reverted and handling of the AP properly
cleaned up.

https://bugzilla.redhat.com/show_bug.cgi?id=1025371

Signed-off-by: Thomas Haller <thaller@redhat.com>
This commit is contained in:
Thomas Haller 2013-11-01 10:32:27 +01:00
parent 3de7ede146
commit 788eed99de

View file

@ -2313,7 +2313,7 @@ supplicant_iface_state_cb (NMSupplicantInterface *iface,
*/
if (devstate == NM_DEVICE_STATE_CONFIG) {
NMAccessPoint *ap = nm_device_wifi_get_activation_ap (self);
const GByteArray *ssid = nm_ap_get_ssid (ap);
const GByteArray *ssid = ap ? nm_ap_get_ssid (ap) : NULL;
nm_log_info (LOGD_DEVICE | LOGD_WIFI,
"Activation (%s/wireless) Stage 2 of 5 (Device Configure) "
@ -2593,9 +2593,8 @@ supplicant_connection_timeout_cb (gpointer user_data)
g_assert (priv->mode == NM_802_11_MODE_INFRA);
ap = nm_device_wifi_get_activation_ap (self);
g_assert (ap);
if (priv->ssid_found && is_encrypted (ap, connection)) {
if (priv->ssid_found && ap && is_encrypted (ap, connection)) {
guint64 timestamp = 0;
gboolean new_secrets = TRUE;
@ -2944,7 +2943,11 @@ act_stage2_config (NMDevice *dev, NMDeviceStateReason *reason)
g_assert (req);
ap = nm_device_wifi_get_activation_ap (self);
g_assert (ap);
if (!ap) {
nm_log_warn (LOGD_DEVICE | LOGD_WIFI, "act_stage2_config failed due to unexpected missing activation_ap. Abort");
*reason = NM_DEVICE_STATE_REASON_SUPPLICANT_DISCONNECT;
goto out;
}
connection = nm_act_request_get_connection (req);
g_assert (connection);
@ -3102,7 +3105,6 @@ handle_ip_config_timeout (NMDeviceWifi *self,
}
ap = nm_device_wifi_get_activation_ap (self);
g_assert (ap);
/* If IP configuration times out and it's a static WEP connection, that
* usually means the WEP key is wrong. WEP's Open System auth mode has
@ -3111,7 +3113,7 @@ handle_ip_config_timeout (NMDeviceWifi *self,
* types (open, WPA, 802.1x, etc) if the secrets/certs were wrong the
* connection would have failed before IP configuration.
*/
if (is_static_wep (ap, connection) && (may_fail == FALSE)) {
if (ap && is_static_wep (ap, connection) && (may_fail == FALSE)) {
/* Activation failed, we must have bad encryption key */
nm_log_warn (LOGD_DEVICE | LOGD_WIFI,
"Activation (%s/wireless): could not get IP configuration for "
@ -3203,7 +3205,7 @@ activation_success_handler (NMDevice *dev)
/* If the AP isn't fake, it was found in the scan list and all its
* details are known.
*/
if (!nm_ap_get_fake (ap))
if (!ap || !nm_ap_get_fake (ap))
goto done;
/* If the activate AP was fake, it probably won't have a BSSID at all.