]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Do not save an invalid network block in wpa_supplicant.conf
authorJouni Malinen <j@w1.fi>
Thu, 24 Nov 2011 20:30:15 +0000 (22:30 +0200)
committerJouni Malinen <j@w1.fi>
Thu, 24 Nov 2011 20:47:32 +0000 (22:47 +0200)
wpa_supplicant is going to reject a configuration file that uses
WPA/WPA2-Personal (the default key_mgmt), but does not define
passphrase/PSK. Refuse to save such a configuration to avoid getting
stuck with a configuration that wpa_supplicant will reject.

Signed-hostap: Jouni Malinen <j@w1.fi>

wpa_supplicant/config_file.c

index d87bd0d4b5408e5036b594b85f3022a9a010ce25..33d0d4ddf78505ad3104dee78e9effb7e741ad25 100644 (file)
@@ -753,6 +753,9 @@ int wpa_config_write(const char *name, struct wpa_config *config)
        for (ssid = config->ssid; ssid; ssid = ssid->next) {
                if (ssid->key_mgmt == WPA_KEY_MGMT_WPS || ssid->temporary)
                        continue; /* do not save temporary networks */
+               if (wpa_key_mgmt_wpa_psk(ssid->key_mgmt) && !ssid->psk_set &&
+                   !ssid->passphrase)
+                       continue; /* do not save invalid network */
                fprintf(f, "\nnetwork={\n");
                wpa_config_write_network(f, ssid);
                fprintf(f, "}\n");