Skip to content

SCP: let the application start the transfer - #1231

Open
ejohnstown wants to merge 2 commits into
wolfSSL:masterfrom
ejohnstown:ccb-phase2-4b
Open

SCP: let the application start the transfer#1231
ejohnstown wants to merge 2 commits into
wolfSSL:masterfrom
ejohnstown:ccb-phase2-4b

Conversation

@ejohnstown

Copy link
Copy Markdown
Contributor

An application that binds an "scp ..." command to a channel itself has no
way to run the transfer; wolfSSH_accept() did it through a WS_SCP_INIT
re-entry only that state machine can drive.

  • Add wolfSSH_SCP_accept(), a wrapper over DoScpRequest() reporting
    WS_SCP_COMPLETE for any non-negative result, as accept() does.
  • Report a receive-side want as itself so the caller can retry, and clear
    a stale want on entry the way the other re-entrant entry points do.

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.

🟡 Changes recommended

The new public API entry point is not covered by tests, and the repository already has SCP-related tests that should be extended to lock in the new retry/completion contract.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR exposes a server-side SCP transfer driver (wolfSSH_SCP_accept()) so applications that bind an "exec scp ..." command to a channel can initiate and drive the SCP transfer themselves, instead of relying on wolfSSH_accept()’s WS_SCP_INIT re-entry behavior.

Changes:

  • Added a new public server-side API: wolfSSH_SCP_accept(WOLFSSH* ssh) in wolfssh/wolfscp.h.
  • Implemented wolfSSH_SCP_accept() as a wrapper around DoScpRequest() that normalizes completion to WS_SCP_COMPLETE and surfaces WS_WANT_READ/WS_WANT_WRITE for non-blocking retry loops.
  • Cleared stale WS_WANT_* error state on entry to match re-entrant retry behavior used elsewhere.
File summaries
File Description
wolfssh/wolfscp.h Adds the public API declaration and documents intended server-side usage/contract.
src/wolfscp.c Implements wolfSSH_SCP_accept() wrapper logic around DoScpRequest() with non-blocking retry semantics.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/wolfscp.c
@ejohnstown ejohnstown self-assigned this Sep 3, 2026
@ejohnstown
ejohnstown removed the request for review from wolfSSL-Fenrir-bot September 4, 2026 04:35
An application that binds an "scp ..." command to a channel itself has no
way to run the transfer; wolfSSH_accept() did it through a WS_SCP_INIT
re-entry only that state machine can drive.

- add wolfSSH_SCP_accept(), a wrapper over DoScpRequest() reporting
  WS_SCP_COMPLETE for any non-negative result, as accept() does
- a receive-side want reaches the wrapper as a generic error with the
  want in ssh->error, so report the want itself and let the caller retry
- state that resume contract beside the prototype, and clear a stale want
  on entry the way the other re-entrant entry points do

@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 #1231

Scan targets checked: wolfssh-bugs, wolfssh-src

Findings: 2
2 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Reported findings require changes before merge.

Comment thread src/wolfscp.c Outdated
Comment thread src/wolfscp.c Outdated
wolfSSH_SCP_accept() reported any want held in ssh->error in place of
the DoScpRequest() result. A short send that SendChannelData() accepts
leaves WS_WANT_WRITE there with nothing clearing it on a later flush,
so a terminal result came back as retryable and the retry re-entered
the state machine, re-sending an abort confirmation or reading past a
bad message.

- Substitute the want only when the result is WS_FATAL_ERROR and the
  want is WS_WANT_READ, the one case GetInputData() hides by value.
- Leave write wants alone; the SCP state machine already returns them.
Comment thread src/wolfscp.c Outdated
Comment thread src/wolfscp.c Outdated

@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 #1231

Scan targets checked: wolfssh-bugs, wolfssh-src

Fenrir result: Approved ✅

No new issues found in the changed files.

Advisory only — this automated result does not count as a GitHub approval.

@wolfSSL-Fenrir-bot
wolfSSL-Fenrir-bot dismissed their stale review September 5, 2026 00:16

Fenrir's latest completed scan found no issues; clearing the prior automated change request.

@ejohnstown
ejohnstown requested a review from philljj September 5, 2026 08:29
@ejohnstown ejohnstown assigned wolfSSL-Bot and unassigned ejohnstown Sep 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants