This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new 673dcb8df wapi: use strlen to calc the length of ssid
673dcb8df is described below

commit 673dcb8df86d13e471a5ac4a6d51a892a0dc72af
Author: zhanghongyu <[email protected]>
AuthorDate: Wed Feb 28 14:18:13 2024 +0800

    wapi: use strlen to calc the length of ssid
    
    Avoid wrq.u.essid.length being different from the actual length
    
    Signed-off-by: zhanghongyu <[email protected]>
---
 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);

Reply via email to