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

   ## Summary
   
   **nshlib: Fix base64dec corrupting binary output.**
   
   * The decoded data was printed with nsh_output("%s"), which stops at
     the first NUL byte, so everything after a zero byte in each chunk was
     silently dropped.  Decoding any binary file (e.g. a WAV header) gave
     a truncated, corrupted result.  Write decoded base64 by length.
   * The base64 callbacks passed an int pointer cast to size_t * as the
     output length, so the codec wrote a size_t into an int, overwriting
     the adjacent stack slot on 64-bit targets.  Use a size_t temporary.
   
   Tested on Waveshare ESP32-S3-Touch-AMOLED-2.16: decoding a 38444-byte
   WAV file now reproduces it byte for byte (header and tail compared);
   before it produced 25494 bytes with the header mangled.
   
   The last commit fixes the pre-existing nxstyle errors in the touched file 
(whitespace only, no functional change), as CI checks whole files.
   
   ## Impact
   
   * Is new feature added? Is existing feature changed? NO
   * Impact on user (will user need to adapt to change)? NO
   * Impact on build (will build process change)? NO
   * Impact on hardware (will arch(s) / board(s) / driver(s) change)? NO
   * Impact on documentation (is update required / provided)? NO
   * Impact on security (any sort of implications)? NO
   * Impact on compatibility (backward/forward/interoperability)? NO
   
   ## Testing
   
   I confirm that changes are verified on local setup and works as intended:
   * Build Host(s): Linux x86_64, xtensa-esp-elf GCC 15.2.0 
(esp-15.2.0_20251204), riscv32-esp-elf GCC 15.2.0 for the ESP32-C3 build.
   * Target(s): Waveshare ESP32-S3-Touch-AMOLED-2.16 (ESP32-S3R8, 16 MB flash, 
8 MB PSRAM).
   * base64dec -f of a 38444-byte WAV file written with echo lines, compared 
with the original.
   
   Builds (each on current master plus this PR only):
   
   * PASS pr/base64dec-binary devkit esp32s3-devkit:nsh (warnings: 0)
   
   Testing logs before change:
   
   ```
   25494 bytes written, header mangled.
   ```
   
   Testing logs after change:
   
   ```
   38444 bytes, identical (header and tail compared).
   ```
   
   ## PR verification Self-Check
   
   * [x] This PR introduces only one functional change.
   * [x] I have updated all required description fields above.
   * [x] My PR adheres to Contributing Guidelines and Documentation (git commit 
title and message, coding standard, etc).
   * [ ] My PR is still work in progress (not ready for review).
   * [x] My PR is ready for review and can be safely merged into a codebase.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
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