Skip to content

Limit SSH client STDERR line buffer to 64 KiB - #51

Merged
clue merged 1 commit into
clue:1.xfrom
clue-labs:buffer-limit
Oct 17, 2026
Merged

clue merged 1 commit into
clue:1.xfrom
clue-labs:buffer-limit

Conversation

@clue

@clue clue commented Oct 17, 2026

Copy link
Copy Markdown
Owner

This changeset limits the SSH client STDERR line buffer to 64 KiB, matching clue/reactphp-ndjson#10. The internal LineSeparatedReader processes the SSH client's STDERR one line at a time, so a line without a newline would previously keep growing the buffer without bounds. Exceeding the limit now terminates the SSH client process, so a pending connection attempt rejects with Buffer size exceeded. OpenSSH limits its own log messages to 1 KiB and connection data never passes through this buffer, so this should not affect normal operation.

Builds on top of #50 and #8
Resolves / closes #34
Refs clue/reactphp-ndjson#10

@clue clue added the new feature New feature or request label Oct 17, 2026
@clue clue added this to the v1.5.0 milestone Oct 17, 2026
@clue
clue requested a balanced review from Copilot October 17, 2026 16:26

Copilot AI 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.

🟢 Approval recommended

The focused changes have regression coverage across both connectors, with no unresolved review findings.

No open issues 🎉

What changed in this PR

Limits SSH client STDERR buffering to prevent unbounded memory growth from unterminated lines.

Changes:

  • Adds a 64 KiB line-buffer limit.
  • Terminates SSH processes on STDERR errors in both connectors.
  • Adds boundary and overflow regression tests.
File Description
tests/​Io/​LineSeparatedReaderTest.php Tests line-length boundaries and overflow handling.
tests/​IntegrationSshSocksConnectorTest.php Tests SOCKS connection rejection on overflow.
tests/​IntegrationSshProcessConnectorTest.php Tests process connection rejection on overflow.
src/​SshSocksConnector.php Terminates the process on STDERR errors.
src/​SshProcessConnector.php Terminates the process on STDERR errors.
src/​Io/​LineSeparatedReader.php Enforces the buffer limit and reports overflow.

Review effort: Balanced

@clue
clue merged commit 0d4ac33 into clue:1.x Oct 17, 2026
16 checks passed
@clue
clue deleted the buffer-limit branch October 17, 2026 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Limit buffer size for internal LineSeparatedReader

2 participants