wapi: use strlen to calc the length of ssid

Avoid wrq.u.essid.length being different from the actual length

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
This commit is contained in:
zhanghongyu 2024-02-28 14:18:13 +08:00 committed by Xiang Xiao
parent 5f166c09be
commit 673dcb8df8

View File

@ -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);