]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
wpa_supplicant: Use unique IDs for networks and credentials
authorNaïm Favier <n@monade.li>
Mon, 7 Feb 2022 20:01:39 +0000 (21:01 +0100)
committerJouni Malinen <j@w1.fi>
Sat, 9 Apr 2022 15:47:01 +0000 (18:47 +0300)
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 <n@monade.li>
wpa_supplicant/config_file.c

index 2dd586391e9e521d232ff5236f7b8f3b08259dc7..9e7118532367a1432744ffe19da2a6cf4ad9ffd8 100644 (file)
@@ -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;