wifi: return error for AddAndActivate requests for hidden APs

If there's no SSID, we can't connect at all.  So if a client passes
in a hidden AP, and doesn't send the SSID in the partial connection
info, we can't make a connection with it.  Return an error instead
of crashing.
This commit is contained in:
Dan Williams
2011-05-18 10:22:25 -05:00
parent 60c1870674
commit 5f073ece4b

View File

@@ -1460,6 +1460,26 @@ real_complete_connection (NMDevice *device,
if (ap) {
ssid = nm_ap_get_ssid (ap);
if (ssid == NULL) {
/* The AP must be hidden. Connecting to a WiFi AP requires the SSID
* as part of the initial handshake, so check the connection details
* for the SSID. The AP object will still be used for encryption
* settings and such.
*/
ssid = nm_setting_wireless_get_ssid (s_wifi);
}
if (ssid == NULL) {
/* If there's no SSID on the AP itself, and no SSID in the
* connection data, then we cannot connect at all. Return an error.
*/
g_set_error_literal (error,
NM_WIFI_ERROR,
NM_WIFI_ERROR_CONNECTION_INVALID,
"A 'wireless' setting with a valid SSID is required for hidden access points.");
return FALSE;
}
/* If the SSID is a well-known SSID, lock the connection to the AP's
* specific BSSID so NM doesn't autoconnect to some random wifi net.
*/