Repository navigation
common: bound stream header bytes and elems in acquireRecv() - #114
Merged
Merged
Conversation
StreamEndpoint::acquireRecv() takes the payload length and element count from the peer's stream header. With a TCP stream, a header whose bytes field is larger than the endpoint buffer makes the recv loop write past the buffer, and an elems count larger than the channel buffer makes the caller read past it. Reject a header whose bytes exceed the buffer or whose elems exceed the per-channel buffer size, and treat a zero-length recv (peer closed) as an error so the loop can't spin.
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.
StreamEndpoint::acquireRecv()trusts thebytesandelemsfields of the stream header. With a TCP stream, a frame announcing more bytes than the endpoint buffer makes the recv loop write past it, and anelemscount larger than the channel buffer makes the driver read past it. The server acceptsMAKEandSETUP_STREAMwithout auth, so any client that can reach it can open a TX stream and send such a frame.This rejects a header whose
bytesexceeds the buffer or whoseelemsexceeds the per-channel buffer size, and treats a zero-length recv as an error so the loop doesn't spin when the peer closes.I reported this to Christian by email first and he suggested a PR. Built on current master (Ubuntu 24.04, libsoapysdr-dev) with no warnings. Against 0.5.3 with the same change, the oversized frames are rejected and normal TX streaming still works.