Extended (stderr) data: accumulation and window flow control#1054
Open
ejohnstown wants to merge 2 commits into
Open
Extended (stderr) data: accumulation and window flow control#1054ejohnstown wants to merge 2 commits into
ejohnstown wants to merge 2 commits into
Conversation
- PutBuffer appends instead of resetting, preserving unread stderr across multiple packets. - Ignore unknown EXTENDED_DATA type codes per RFC instead of returning WS_INVALID_EXTDATA. Issues: F-864, F-2078
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates wolfSSH’s handling of SSH_MSG_CHANNEL_EXTENDED_DATA (stderr) to (1) accumulate unread extended data instead of overwriting it, (2) ignore unknown extended-data type codes per RFC behavior, and (3) apply channel window back-pressure semantics for stderr by charging the receive window on receipt and replenishing it only when the application drains the buffered stderr.
Changes:
- Accumulate buffered stderr across multiple packets and preserve unread data ordering.
- Implement receive-window accounting for stderr (charge on receipt; replenish on
wolfSSH_extended_data_read()), including a documented single-session limitation for multi-channel stderr buffering. - Add unit test coverage for accumulation, window back-pressure, overflow rejection, unknown-type ignore, and cross-channel fail-safe behavior.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| wolfssh/ssh.h | Documents the public contract for draining stderr and the single-channel buffering limitation. |
| wolfssh/internal.h | Adds internal tracking (extDataChannelId) and documents shared-buffer/window semantics. |
| wolfssh/error.h | Clarifies WS_INVALID_EXTDATA is retained for compatibility but no longer produced. |
| src/internal.c | Changes stderr buffering to append; adds window charging and unknown-type ignore behavior. |
| src/ssh.c | Updates wolfSSH_extended_data_read() to replenish window on drain and gate sends during KEX. |
| tests/unit.c | Adds a comprehensive unit test for extended-data accumulation + window flow control. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Charge the channel window on receipt; replenish only when the application consumes bytes via wolfSSH_extended_data_read. - Track extDataChannelId so the read path adjusts the right window. - Reject extended data larger than the advertised window. - stderr now shares the channel window with normal data (RFC 4254 section 5.2 back-pressure). - Gate window adjusts on isKeying both ways: IsMessageAllowed does not gate connection-layer messages, so they must not go out between KEXINIT and NEWKEYS (RFC 4253 section 7.1). The read path returns WS_REKEYING; the receive path parks owed credit in pendingWindowAdjust, flushed by SendPendingChannelWindowAdjust once keying completes. - Fail safe when a second channel sends stderr while another still has unread data: drop it and replenish its window instead of leaking the displaced channel's window and over-crediting the survivor. - Document the mandatory-drain contract in the public header. Issue: F-864
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.
Issues: F-864, F-2078