Skip to content

Add wolfSSH_ChannelIdPeek() - #1270

Merged
philljj merged 2 commits into
wolfSSL:masterfrom
ejohnstown:chanid-peek
Sep 22, 2026
Merged

philljj merged 2 commits into
wolfSSL:masterfrom
ejohnstown:chanid-peek

Conversation

@ejohnstown

@ejohnstown ejohnstown commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

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.

  • wolfSSH_ChannelIdPeek() carries wolfSSH_stream_peek()'s contract, but names its channel and peeks during a rekey
  • 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 unconsumed bytes, the rekey case, and both drained reports
  • the SFTP test gives the echoserver thread and the client their own argv, since the server thread holds ser.argv for as long as it runs

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
Copilot AI lite review requested due to automatic review settings September 21, 2026 21:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@philljj philljj left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me

@philljj
philljj merged commit c34ac17 into wolfSSL:master Sep 22, 2026
230 of 232 checks passed
@ejohnstown
ejohnstown deleted the chanid-peek branch September 22, 2026 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants