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 dfd6e0847b87cd7d992ac17b946414d265af06f2
Author: wenquan1 <[email protected]>
AuthorDate: Mon Sep 7 16:45:48 2026 +0800

    wireless/wapi: fix NULL pointer dereference in wapi_json_update
    
    wapi_json_update() passes the value argument directly to strcmp()
    without checking for NULL first. When wpa_driver_wext_get_key_ext()
    fails and conf.passphrase remains NULL, calling wapi_save_config()
    triggers strcmp(NULL, obj->valuestring), which causes a Data Abort
    (NULL pointer dereference) and system panic.
    
    Fix this by checking value and obj->valuestring for NULL before
    calling strcmp(). This ensures wapi_save_config() handles the case
    gracefully when the driver fails to return the passphrase.
    
    Signed-off-by: wenquan1 <[email protected]>
    Assisted-by: Kiro:claude-opus-4
---
 wireless/wapi/src/util.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/wireless/wapi/src/util.c b/wireless/wapi/src/util.c
index db4ab5e22..ceda90e53 100644
--- a/wireless/wapi/src/util.c
+++ b/wireless/wapi/src/util.c
@@ -144,18 +144,21 @@ static bool wapi_json_update(FAR cJSON *root,
         }
       else
         {
-          int len = strlen(obj->valuestring);
-
-          if (len > 0)
+          if (value == NULL)
             {
-              if (!strcmp(value, obj->valuestring))
+              if (obj->valuestring == NULL ||
+                  strlen(obj->valuestring) == 0)
                 {
                   return false;
                 }
             }
-          else if (len == 0 && value == NULL)
+          else
             {
-              return false;
+              if (obj->valuestring != NULL &&
+                  !strcmp(value, obj->valuestring))
+                {
+                  return false;
+                }
             }
 
           item = cJSON_CreateString(value);

Reply via email to