Skip to content

wolfsshd: drain stderr before ending the session - #1314

Open
ejohnstown wants to merge 3 commits into
wolfSSL:masterfrom
ejohnstown:shell-stderr-drain
Open

ejohnstown wants to merge 3 commits into
wolfSSL:masterfrom
ejohnstown:shell-stderr-drain

Conversation

@ejohnstown

Copy link
Copy Markdown
Contributor

A child that exits with error output still in its stderr pipe had only one bufferful of it relayed, by the drain after the shell loop, so the peer saw a truncated error stream and no error. The loop now waits for stderr EOF the way it waits for stdout.

  • wolfsshd: wait on stderr in the shell loop; a pty session has no stderr pipe to wait on
  • tests: sshd_stderr_drain_test.sh has the child queue its whole payload in a grown pipe and checks every line arrives

The shell loop waits on the child's stderr the way it already waits on
its stdout. A child that exits with error output still in the pipe had
the rest relayed only by the single read below the loop -- one
bufferful, however much was waiting -- so the peer saw a truncated
error stream and no error. A pty session has no stderr of its own.
A child that exits with its error output still in the pipe must have
all of it relayed. The child grows its stderr pipe and queues the
whole payload before exiting, so the result does not depend on the
pipe size or on which cat is installed.

- forty passes, counted in whole lines
- a client failure is reported as one, not as a truncation
- skips without perl
- the external-host tally counts 13 local-only tests
Copilot AI balanced review requested due to automatic review settings October 12, 2026 20:51

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.

🟢 Approval recommended

The implementation correctly handles PTY and non-PTY sessions and includes focused regression coverage.

0 open findings

What changed in this PR

Ensures wolfsshd fully relays child stderr before closing the session.

Changes:

  • Waits for stderr EOF alongside stdout.
  • Adds and registers a regression test for stderr truncation.
File Description
apps/​wolfsshd/​wolfsshd.c Drains stderr before session shutdown.
apps/​wolfsshd/​test/​sshd_stderr_drain_test.sh Tests complete stderr delivery.
apps/​wolfsshd/​test/​run_all_sshd_tests.sh Registers the new test.

🧠 Review effort: Balanced


💡 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 #1314

Scan targets checked: wolfssh-src, wolfssh-bugs
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

A pty session has no stderr pipe, so the shell loop must start with
stderrEmpty set. The drain test now runs "exit 3" in a pty shell and
expects the session to end with that status rather than wait for a
stderr EOF that never comes.

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

Scan targets checked: none
Unchanged since last review (not re-run): 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.

Review tier: Lite

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