From 0adc67612dab5a81088a832b1fd9629d3a2cada8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Na=C3=AFm=20Favier?= Date: Mon, 7 Feb 2022 21:01:39 +0100 Subject: [PATCH] wpa_supplicant: Use unique IDs for networks and credentials MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 commit eadfeb0e9374 ("wpa_gui: Show entire list of networks"), 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 --- 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 2dd586391..9e7118532 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;