Add wolfSSH_ChannelIdPeek() - #1270
Merged
Merged
Conversation
wolfSSH_SftpTest() gives the echoserver thread and the SFTP client each their own argument array. The server thread keeps ser.argv pointing at its array for as long as it runs, so the two cannot share one.
wolfSSH_ChannelIdPeek() reports what is buffered on the channel named by channelId without consuming it or crediting the window. It carries wolfSSH_stream_peek()'s contract, except that wolfSSH_stream_peek() only ever peeks the first channel in the list, and this peeks during a rekey the way wolfSSH_ChannelIdRead() reads during one. - a NULL buf asks only for the count, still capped at bufSz - a drained channel reports WS_EOF, or WS_DISCONNECT once the session is gone - test_ChannelIdPeek() covers the count, the bytes left unconsumed, the rekey case, and both drained reports
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
Only a minor, non-blocking test coverage nit remains.
Review effort: Lite
Findings: None
What changed in this PR
Adds wolfSSH_ChannelIdPeek(), a non-consuming, channel-specific peek API with rekey and drained-channel handling.
Changes:
- Declares and implements the new API.
- Adds unit coverage for buffering, rekeying, EOF, and disconnect behavior.
- Separates SFTP server/client argument arrays for thread safety.
| File | Summary |
|---|---|
wolfssh/ssh.h |
Declares and documents the new API. |
src/ssh.c |
Implements channel-buffer peeking. |
tests/unit.c |
Tests peek behavior and terminal statuses; minor coverage nit remains for multiple channels. |
tests/sftp.c |
Prevents shared argv mutation between threads. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #1270
Scan targets checked: wolfssh-src, wolfssh-bugs
Fenrir result: Approved ✅
No new issues found in the changed files.
Advisory only — this automated result does not count as a GitHub approval.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a peek counterpart to wolfSSH_ChannelIdRead(): it reports what is buffered on the channel named by channelId without consuming it or crediting the window.