Skip to content

common: bound stream header bytes and elems in acquireRecv() - #114

Merged
zuckschwerdt merged 1 commit into
pothosware:masterfrom
DicksonWu654:fix-stream-bounds
Nov 13, 2026
Merged

zuckschwerdt merged 1 commit into
pothosware:masterfrom
DicksonWu654:fix-stream-bounds

Conversation

@DicksonWu654

Copy link
Copy Markdown
Contributor

StreamEndpoint::acquireRecv() trusts the bytes and elems fields 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 an elems count larger than the channel buffer makes the driver read past it. The server accepts MAKE and SETUP_STREAM without auth, so any client that can reach it can open a TX stream and send such a frame.

This rejects a header whose bytes exceeds the buffer or whose elems exceeds 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.

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.
@zuckschwerdt
zuckschwerdt merged commit 443193d into pothosware:master Nov 13, 2026
54 checks passed
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.

2 participants