Repository navigation
Limit SSH client STDERR line buffer to 64 KiB - #51
Merged
Merged
Conversation
There was a problem hiding this comment.
🟢 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This changeset limits the SSH client
STDERRline buffer to 64 KiB, matching clue/reactphp-ndjson#10. The internalLineSeparatedReaderprocesses the SSH client'sSTDERRone 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 withBuffer 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