JianyuWang0623 opened a new pull request, #3435:
URL: https://github.com/apache/nuttx-apps/pull/3435

   *Note: Please adhere to [Contributing 
Guidelines](https://github.com/apache/nuttx/blob/master/CONTRIBUTING.md).*
   
   ## Summary
   
   `system/nxrecorder/nxrecorder_main.c` contains a command parsing loop that 
trims leading spaces from the `arg` string returned by `strtok_r()`. When a 
command takes no arguments (e.g., `q`, `quit`, `stop`), `strtok_r()` returns 
`NULL` for `arg`. The original loop `while (*arg == ' ')` unconditionally 
dereferenced `arg` without a null check, causing undefined behavior — 
manifesting as a system hang on ESP32-S3.
   
   The fix adds a null guard before the dereference:
   
   ```c
   - while (*arg == ' ')
   + while (arg && *arg == ' ')
   ```
   
   ## Impact
   
   - Fixes a null pointer dereference in `nxrecorder_main.c` argument parsing.
   - Affects any target running `nxrecorder` where no-argument commands (`q`, 
`quit`, `stop`, etc.) are used interactively.
   - No API, ABI, or configuration changes. No new dependencies introduced.
   - Improves stability and prevents undefined behavior / system hang when 
issuing argument-less commands.
   
   ## Testing
   
   - Host: Linux x86_64
   - Target: ESP32-S3 (`lckfb-szpi-esp32s3:nsh` or equivalent config)
   - Verified that issuing the `quit` (and `q`, `stop`) command in `nxrecorder` 
no longer causes a system hang.
   - Before fix: entering `quit` with no arguments caused a null pointer 
dereference and the system hung.
   - After fix: `quit` exits cleanly as expected.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to