From 673dcb8df86d13e471a5ac4a6d51a892a0dc72af Mon Sep 17 00:00:00 2001 From: zhanghongyu Date: Wed, 28 Feb 2024 14:18:13 +0800 Subject: [PATCH] wapi: use strlen to calc the length of ssid Avoid wrq.u.essid.length being different from the actual length Signed-off-by: zhanghongyu --- wireless/wapi/src/wireless.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wireless/wapi/src/wireless.c b/wireless/wapi/src/wireless.c index f7b9f08b0..92eba66a1 100644 --- a/wireless/wapi/src/wireless.c +++ b/wireless/wapi/src/wireless.c @@ -773,9 +773,9 @@ int wapi_set_essid(int sock, FAR const char *ifname, FAR const char *essid, /* Prepare request. */ + snprintf(buf, sizeof(buf), "%s", essid); wrq.u.essid.pointer = buf; - wrq.u.essid.length = - snprintf(buf, ((WAPI_ESSID_MAX_SIZE + 1) * sizeof(char)), "%s", essid); + wrq.u.essid.length = strlen(buf); wrq.u.essid.flags = flag; strlcpy(wrq.ifr_name, ifname, IFNAMSIZ);