aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Shmidt <dimitrysh@google.com>2018-02-01 00:34:54 +0000
committerDmitry Shmidt <dimitrysh@google.com>2018-02-05 10:32:57 -0800
commite3d76d9c1d0848c7b57e73aed3c5a1aa3835139f (patch)
treef9ec9902886809f3985c56a92d5a5dab2f4becc0
parent18db0829f5c0e6b67f9593d166df5fc357c9d4eb (diff)
downloadwpa_supplicant_8-e3d76d9c1d0848c7b57e73aed3c5a1aa3835139f.tar.gz
wpa_supplicant: Free config only if it was allocated in same call
(cherry-picked from 9c5fe742a25d2361b49051aef5b1ed0083494b6c) 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. Bug: 72740284 Test: Manual Change-Id: I11f36fb5f77b3fca033268c8d16656679c356054 Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
-rw-r--r--wpa_supplicant/config_file.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/wpa_supplicant/config_file.c b/wpa_supplicant/config_file.c
index 6b7abe2b..0d708507 100644
--- a/wpa_supplicant/config_file.c
+++ b/wpa_supplicant/config_file.c
@@ -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;
}