Repository navigation
Stop two ignored return values hiding failures - #1397
ejohnstown wants to merge 3 commits into
Conversation
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #1397
Scan targets checked: wolfssh-src, wolfssh-bugs
Coverage: 4 of 4 in-scope changed file(s) opened by the reviewer
Fenrir result: Approved ✅
No new issues found in the changed files.
Advisory only — this automated result does not count as a GitHub approval.
Review tier: Max
|
@claude review |
There was a problem hiding this comment.
I reviewed this PR and didn't find any bugs. The fixes are small, but they touch the transport's rekey-trigger path and SFTP read buffering, and an earlier automated review on this PR has had no follow-up commit, so a human look would still be worthwhile.
What was reviewed:
- HighwaterCheck: a positive callback result is now changed to WS_SUCCESS and negative results still pass through, which matches the new test_ByteHighwater cases.
- SendReadPacket remainder loop: if
retis larger than the remaining size, the unsigned subtraction wraps to a value bigger thanbuffer->sz.wolfSSH_SFTP_buffer_set_sizerejects that, so the loop now exits to cleanup beforerecvSzor the output offset is advanced. - client.c readPeer: a fatal worker result during rekey now leaves
retnegative, which ends the outerwhile (ret >= 0)loop. Non-fatal codes are still mapped to 0.
Extended reasoning...
The change touches src/internal.c (the highwater callback that triggers rekeying), src/wolfsftp.c (SFTP read buffer bounds), the example client, and a unit test. Together that is about 40 lines. It touches security-sensitive surface: SSH key-lifetime limits and how SFTP received data is bounded into the caller's buffer. No bugs were found, and no CODEOWNERS file covers these paths. I deferred instead of approving because this is security-critical library code and the timeline has a third-party review whose content I can't see, with no later commit addressing it.
HighwaterCheck() hands the application callback's result back through wolfSSH_SendPacket() into wolfSSH_stream_read(), which returns it as a byte count. A positive result now comes back as WS_SUCCESS. - sftp: check buffer_set_size() in SendReadPacket's remainder loop, so a count over the request ends the read instead of overrunning out - tests: cover positive and negative callback results in ByteHighwater Issue: CID-662152
wolfSSH_stream_read() keeps answering WS_REKEYING while a key exchange runs, so a transport that dies mid-rekey is reported only by the wolfSSH_worker() call that drives it. readPeer() now ends the session on any worker result that is not a session status, instead of spinning. Issue: CID-662153
The receive loop looks for the newline in scpRecvMsgSz bytes and sets sz from the newline offset after the loop, so copying scpRecvMsgSz into sz after each read is never used. Issue: CID-662317
Both ignored returns hid real failures: one let a positive highwater
callback result read as a byte count, the other spun the example client
forever when the transport died mid-rekey.
buffer_set_size() in SendReadPacket so an over-count cannot overrun
the caller's buffer (CID 662152)
(CID 662153)