shikhabhadoria opened a new pull request, #22567:
URL: https://github.com/apache/nuttx/pull/22567

   fs/procfs: Ignore a failed vsnprintf in procfs_sprintf.
   
   ## Summary
   
     * `procfs_sprintf()` stored the `vsnprintf()` result in `size_t`. A 
failure (`-1`) became `SIZE_MAX`, then `MIN(..., LINEBUF_SIZE - 1)` copied 127 
bytes from an uninitialized `linebuf`.
     * Keep the result in an `int`, return without `memcpy` when `n < 0`, then 
cap a successful length as before.
     * Related issue: https://github.com/apache/nuttx/issues/22566
     * Leftover of #22550, which fixed the same promotion in 
`procfs_snprintf()`.
   
   ## Impact
   
     * Is new feature added? Is existing feature changed? NO. Bugfix of the 
failed-format path.
     * Impact on user? NO.
     * Impact on build? NO.
     * Impact on hardware? NO. Architecture-independent C.
     * Impact on documentation? YES. Function comment notes that a failed 
`vsnprintf()` copies nothing.
     * Impact on security? YES. The old path could expose uninitialized stack 
through procfs.
     * Impact on compatibility? NO. Successful formats are unchanged.
   
   ## Testing
   
     I confirm that changes are verified on local setup and works as intended:
     * Build Host(s): Ubuntu 24.04, x86_64, gcc 13.3.0
     * Target(s): host unit test of the length mapping (arch-independent helper)
   
   ```
   $ ./tools/checkpatch.sh -f fs/procfs/fs_procfsutil.c 
include/nuttx/fs/procfs.h
   All checks pass.
   ```
   
   ```
   PASS old n=-1: 127
   PASS new n=-1: 0
   PASS new n=0: 0
   PASS new n=5: 5
   PASS new n=127: 127
   PASS new n=128: 127
   PASS new n=200: 127
   ALL TESTS PASSED
   ```


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