WPS: add null-terminator to ssid

Alexander Pogudaev apogudaev at dlink.ru
Thu Nov 16 01:54:15 PST 2023


Signed-off-by: Alexander Pogudaev <apogudaev at dlink.ru>
---
  wpa_supplicant/wps_supplicant.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/wpa_supplicant/wps_supplicant.c 
b/wpa_supplicant/wps_supplicant.c
index 220a5f8b5..81eb35d40 100644
--- a/wpa_supplicant/wps_supplicant.c
+++ b/wpa_supplicant/wps_supplicant.c
@@ -488,9 +488,10 @@ static int wpa_supplicant_wps_cred(void *ctx,
  	ssid->wps_run = wpa_s->wps_run;
   	os_free(ssid->ssid);
-	ssid->ssid = os_malloc(cred->ssid_len);
+	ssid->ssid = os_malloc(cred->ssid_len + 1);
  	if (ssid->ssid) {
  		os_memcpy(ssid->ssid, cred->ssid, cred->ssid_len);
+		ssid->ssid[cred->ssid_len] = '\0';
  		ssid->ssid_len = cred->ssid_len;
  	}
  -- 2.42.1




More information about the Hostap mailing list