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

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

commit d8c2ede705d857c72d5db684fefee1921521af51
Author: wenquan1 <[email protected]>
AuthorDate: Wed Jul 22 16:38:50 2026 +0800

    wireless/wapi: reject SSID exceeding IW_ESSID_MAX_SIZE in scan
    
    wapi_escan_channel_init() copies the essid into req.essid[IW_ESSID_MAX_SIZE]
    without length validation. When the caller passes an SSID longer than 32
    bytes, memcpy overflows the essid buffer, corrupting subsequent fields
    in struct iw_scan_req on the stack.
    
    Return -EINVAL early if essid_len exceeds IW_ESSID_MAX_SIZE (32) to
    prevent the buffer overflow and signal the invalid parameter to callers.
    
    Signed-off-by: wenquan1 <[email protected]>
    Assisted-by: Kiro:claude-opus-4
---
 wireless/wapi/src/wireless.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/wireless/wapi/src/wireless.c b/wireless/wapi/src/wireless.c
index 039741763..c6a82512c 100644
--- a/wireless/wapi/src/wireless.c
+++ b/wireless/wapi/src/wireless.c
@@ -1228,6 +1228,11 @@ int wapi_escan_channel_init(int sock, FAR const char 
*ifname,
 
   if (essid && (essid_len = strlen(essid)) > 0)
     {
+      if (essid_len > IW_ESSID_MAX_SIZE)
+        {
+          return -EINVAL;
+        }
+
       req.essid_len    = essid_len;
       memcpy(req.essid, essid, essid_len);
       wrq.u.data.flags = IW_SCAN_THIS_ESSID;

Reply via email to