fxysunshine opened a new pull request, #22571:
URL: https://github.com/apache/nuttx/pull/22571
## Summary
* `bufferedoutstream_puts()` declared its return holder as `size_t` and
assigned the result of `lib_stream_flush()` to it. Since `lib_stream_flush()`
may return a negative errno, the subsequent `if (ret >= 0)` check was always
true for an unsigned type, so a flush failure was silently swallowed and the
function reported a bogus huge byte count through its `ssize_t` return.
* Change the holder to `ssize_t` so the negative-errno check works
correctly.
## Impact
* Is new feature added? NO — a bug fix.
* Impact on user? Callers of `lib_bufferedoutstream` (buffered
stdio-style output streams) now see a proper negative error return from
`puts()` when the underlying flush fails, instead of a wrapped huge value.
Success-path byte counts are unchanged.
* Impact on build (will it be compiled on all platforms and
architectures)? No build changes; header type only.
* Impact on documentation? NO.
* Impact on security? NO.
* Impact on compatibility? Callers that (incorrectly) ignored the return
value are unaffected.
## Testing
I confirm that changes are verified on local setup and works as intended:
* Build Host(s): Linux x86_64, Ubuntu 22.04, gcc 13.4.0
* Target(s): `sim:nsh` (Make and CMake builds), `ostest` exits with status 0
* Testing logs before change: `RESULT: PASS` on `upstream/master` at the
merge base (`tools/checkpatch.sh`, sim:nsh make build with `ostest` run, CMake
build)
* Testing logs after change: `RESULT: PASS` on the fix commit (same suite)
* The failure path is exercised through the buffered stdout stream flush
failure handling; the unsigned/signed wraparound is directly visible by
inspection.
* Verified on sim only.
## 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.
Signed-off-by: fangxinyong <[email protected]>
--
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]