[PATCH 5/5] WPS: Fix possible memory leak in wps_er_config_token_from_cred()

Ilan Peer ilan.peer
Wed Jun 17 06:16:36 PDT 2015


From: Ben Rosenfeld <ben.rosenfeld at intel.com>

In wps_er_config_token_from_cred() data.new_pak memory is allocated in
wps_build_cred() and the function returns before the memroy is released.

Signed-off-by: Ben Rosenfeld <ben.rosenfeld at intel.com>
---
 src/wps/wps_er.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/wps/wps_er.c b/src/wps/wps_er.c
index 078ff72..e661fcd 100644
--- a/src/wps/wps_er.c
+++ b/src/wps/wps_er.c
@@ -2039,10 +2039,12 @@ struct wpabuf * wps_er_config_token_from_cred(struct wps_context *wps,
 	data.use_cred = cred;
 	if (wps_build_cred(&data, ret) ||
 	    wps_build_wfa_ext(ret, 0, NULL, 0)) {
+		os_free(data.new_psk);
 		wpabuf_free(ret);
 		return NULL;
 	}
 
+	os_free(data.new_psk);
 	return ret;
 }
 
-- 
1.9.1




More information about the Hostap mailing list