Skip to content

examples: fix short writes and lost sessions - #1388

Open
ejohnstown wants to merge 4 commits into
wolfSSL:masterfrom
ejohnstown:example-short-io
Open

ejohnstown wants to merge 4 commits into
wolfSSL:masterfrom
ejohnstown:example-short-io

Conversation

@ejohnstown

Copy link
Copy Markdown
Contributor

portfwd and the TPM examples no longer lose data on a short write or a
partial echo, and portfwd exits when the SSH session is gone.

  • portfwd writes whole chunks to the app socket and exits nonzero on a
    lost session; fwd-lost.test covers it
  • tpmcertclient reads the whole echo back; tpmcertserver takes only
    the CSR result as a length

Issue: F-12550, F-13908, F-16748, F-16750

The relay and the EOF drain hand channel data to the local socket
through app_write_all(), the helper the echoserver uses, so a short
send() no longer drops the rest of a chunk already taken from the
channel.

Issue: F-13908
@ejohnstown

Copy link
Copy Markdown
Contributor Author

@claude review

@claude claude 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.

Nothing blocking. The comments below are optional suggestions. There is no need to push a fix for them before merging.

Comment thread examples/portfwd/portfwd.c Resolved

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

Scan targets checked: wolfssh-src, wolfssh-bugs
Not reviewed (no scan target covers them): scripts/fwd-lost.test, scripts/include.am
Coverage: 3 of 3 in-scope changed file(s) opened by the reviewer

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

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

Review tier: Max

Comment thread examples/portfwd/portfwd.c Resolved
The forwarding loop leaves on any wolfSSH_worker() status outside the
progress set the reply wait accepts. A fatal error counts as progress
only when it is an idle WS_WANT_READ or WS_WANT_WRITE, so a peer that
hangs up no longer leaves the loop spinning on a readable socket.

- treat a refused open (WS_CHANOPEN_FAILED) as a lost channel, not a
  lost session
- skip the cancel, shutdown and disconnect when the session is gone
- exit with a nonzero return code after a lost session
- add scripts/fwd-lost.test: kill the echoserver under a local and a
  reverse forward, expect a nonzero exit; a refused open exits 0

Issue: F-16748
The client reads until every byte it sent has come back, driving a
rekey with wolfSSH_worker() when stream_read reports one, and fails
unless the echo matches what was sent.

Issue: F-12550
TpmCsMakeKeyAndCert() reads rc as the DER length only right after
wolfTPM2_CSR_Generate_ex(), so a positive TPM_RC from an earlier
wolfTPM step stays a failure.

Issue: F-16750

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

Scan targets checked: wolfssh-src, wolfssh-bugs
Not reviewed (no scan target covers them): scripts/fwd-lost.test, scripts/include.am
Coverage: 1 of 1 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: Lite

@wolfSSL-Fenrir-bot
wolfSSL-Fenrir-bot dismissed their stale review November 11, 2026 23:12

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

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.

3 participants