]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
wpa_supplicant: Free config only if it was allocated in same call
authorDmitry Shmidt <dimitrysh@google.com>
Thu, 1 Feb 2018 00:34:54 +0000 (00:34 +0000)
committerJouni Malinen <j@w1.fi>
Sun, 4 Feb 2018 10:13:12 +0000 (12:13 +0200)
If option -I:config points to a non-existing file, the the previously
allocated config must not be freed. Avoid use of freed memory in such an
error case by skipping the incorrect freeing operation.

Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
wpa_supplicant/config_file.c

index 6f2161ea63898f4fe11cb703e81f62f5c85a7f36..bf0ba173c3e0bd1fec21332c716c25245ebf108a 100644 (file)
@@ -397,7 +397,8 @@ struct wpa_config * wpa_config_read(const char *name, struct wpa_config *cfgp)
        if (f == NULL) {
                wpa_printf(MSG_ERROR, "Failed to open config file '%s', "
                           "error: %s", name, strerror(errno));
-               os_free(config);
+               if (config != cfgp)
+                       os_free(config);
                return NULL;
        }