From 2aa6853d3edf6ea81df590306e9e3a236241fb0b Mon Sep 17 00:00:00 2001 From: Kapil Gupta Date: Thu, 2 Jun 2022 19:09:24 +0530 Subject: [PATCH] Remove strcpy/strncpy function callings from supplicant --- components/wpa_supplicant/port/include/os.h | 3 --- components/wpa_supplicant/src/eap_peer/eap.c | 8 ++++---- components/wpa_supplicant/src/eap_peer/eap_peap.c | 4 ++-- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/components/wpa_supplicant/port/include/os.h b/components/wpa_supplicant/port/include/os.h index 765396794b..06c4c176ab 100644 --- a/components/wpa_supplicant/port/include/os.h +++ b/components/wpa_supplicant/port/include/os.h @@ -281,9 +281,6 @@ char * ets_strdup(const char *s); #ifndef os_strncmp #define os_strncmp(s1, s2, n) strncmp((s1), (s2), (n)) #endif -#ifndef os_strncpy -#define os_strncpy(d, s, n) strncpy((d), (s), (n)) -#endif #ifndef os_strrchr #define os_strrchr(s, c) strrchr((s), (c)) #endif diff --git a/components/wpa_supplicant/src/eap_peer/eap.c b/components/wpa_supplicant/src/eap_peer/eap.c index 1d4b5036e5..1b80c191b0 100644 --- a/components/wpa_supplicant/src/eap_peer/eap.c +++ b/components/wpa_supplicant/src/eap_peer/eap.c @@ -661,7 +661,7 @@ int eap_peer_blob_init(struct eap_sm *sm) ret = -2; goto _out; } - os_strncpy(sm->blob[0].name, CLIENT_CERT_NAME, BLOB_NAME_LEN+1); + os_strlcpy(sm->blob[0].name, CLIENT_CERT_NAME, BLOB_NAME_LEN+1); sm->blob[0].len = g_wpa_client_cert_len; sm->blob[0].data = g_wpa_client_cert; } @@ -672,7 +672,7 @@ int eap_peer_blob_init(struct eap_sm *sm) ret = -2; goto _out; } - os_strncpy(sm->blob[1].name, PRIVATE_KEY_NAME, BLOB_NAME_LEN+1); + os_strlcpy(sm->blob[1].name, PRIVATE_KEY_NAME, BLOB_NAME_LEN+1); sm->blob[1].len = g_wpa_private_key_len; sm->blob[1].data = g_wpa_private_key; } @@ -683,7 +683,7 @@ int eap_peer_blob_init(struct eap_sm *sm) ret = -2; goto _out; } - os_strncpy(sm->blob[2].name, CA_CERT_NAME, BLOB_NAME_LEN+1); + os_strlcpy(sm->blob[2].name, CA_CERT_NAME, BLOB_NAME_LEN+1); sm->blob[2].len = g_wpa_ca_cert_len; sm->blob[2].data = g_wpa_ca_cert; } @@ -694,7 +694,7 @@ int eap_peer_blob_init(struct eap_sm *sm) ret = -2; goto _out; } - os_strncpy(sm->blob[3].name, "blob://", 8); + os_strlcpy(sm->blob[3].name, "blob://", 8); sm->blob[3].len = g_wpa_pac_file_len; sm->blob[3].data = g_wpa_pac_file; } diff --git a/components/wpa_supplicant/src/eap_peer/eap_peap.c b/components/wpa_supplicant/src/eap_peer/eap_peap.c index 866dbee118..498fb060a2 100644 --- a/components/wpa_supplicant/src/eap_peer/eap_peap.c +++ b/components/wpa_supplicant/src/eap_peer/eap_peap.c @@ -1115,9 +1115,9 @@ static struct wpabuf * eap_peap_process(struct eap_sm *sm, void *priv, * label by default, but allow it to be configured with * phase1 parameter peaplabel=1. */ if (data->peap_version > 1 || data->force_new_label) - strcpy(label, "client PEAP encryption"); + os_strlcpy(label, "client PEAP encryption", 24); else - strcpy(label, "client EAP encryption"); + os_strlcpy(label, "client EAP encryption", 24); wpa_printf(MSG_DEBUG, "EAP-PEAP: using label '%s' in " "key derivation", label); data->key_data =