[PATCH] wpa_supplicant: Use unique IDs for networks and credentials

Naïm Favier n at monade.li
Mon Feb 7 12:01:39 PST 2022

The id and cred_id variables are reset to 0 every time the
wpa_config_read function is called, which is fine as long as it is only
called once. However, this is not the case when using both the -c and -I
options to specify two config files.

This is a problem because the GUI, since eadfeb0e93748eb396ae62012b92d21a7f533646,
relies on the network IDs being unique (and increasing), and might get
into an infinite loop otherwise.

This is solved by simply making the variables static.

Signed-off-by: Naïm Favier <n at monade.li>
 wpa_supplicant/config_file.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/wpa_supplicant/config_file.c b/wpa_supplicant/config_file.c
index 6db5010db..c996e3916 100644
--- a/wpa_supplicant/config_file.c
+++ b/wpa_supplicant/config_file.c
@@ -297,8 +297,8 @@ struct wpa_config * wpa_config_read(const char *name, struct wpa_config *cfgp)
 	struct wpa_ssid *ssid, *tail, *head;
 	struct wpa_cred *cred, *cred_tail, *cred_head;
 	struct wpa_config *config;
-	int id = 0;
-	int cred_id = 0;
+	static int id = 0;
+	static int cred_id = 0;
 	if (name == NULL)
 		return NULL;

More information about the Hostap mailing list