Skip to content

[BUG] Reject CRcvBuffer::dropMessage range past buffer end#3322

Merged
cl-ment merged 1 commit into
Haivision:masterfrom
mszatmary-netflix:fix/dropmsg-lo-past-buffer-end
May 21, 2026
Merged

[BUG] Reject CRcvBuffer::dropMessage range past buffer end#3322
cl-ment merged 1 commit into
Haivision:masterfrom
mszatmary-netflix:fix/dropmsg-lo-past-buffer-end

Conversation

@mszatmary-netflix
Copy link
Copy Markdown
Contributor

dropMessage early-returns when offset_b < 0 (the entire range is before the buffer start), but does not symmetrically guard against offset_a >= m_szSize (the entire range is past the buffer end). In that case start_off = offset_a is unbounded; incPos() wraps modulo m_szSize and the loop walks legitimate buffer entries, marking them EntryState_Drop -- corrupting receiver state from a single malformed call.

Add a symmetric early return for offset_a >= m_szSize.

Add CRcvBufferReadMsg.PacketDropLoPastBufferEnd covering the new guard: insert two packets, request a drop whose lo is well past the buffer end, assert no packets were dropped and the buffered packets are still readable.

dropMessage early-returns when offset_b < 0 (the entire range is
before the buffer start), but does not symmetrically guard against
offset_a >= m_szSize (the entire range is past the buffer end).
In that case start_off = offset_a is unbounded; incPos() wraps
modulo m_szSize and the loop walks legitimate buffer entries,
marking them EntryState_Drop -- corrupting receiver state from a
single malformed call.

Add a symmetric early return for offset_a >= m_szSize.

Add CRcvBufferReadMsg.PacketDropLoPastBufferEnd covering the new
guard: insert two packets, request a drop whose lo is well past
the buffer end, assert no packets were dropped and the buffered
packets are still readable.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@ethouris
Copy link
Copy Markdown
Collaborator

If you add here also the check if offset_a <= offset_b, you can dismiss checking entry arguments for UMSG_DROPREQ handler.

@mszatmary-netflix
Copy link
Copy Markdown
Contributor Author

If you add here also the check if offset_a <= offset_b, you can dismiss checking entry arguments for UMSG_DROPREQ handler.

That is true. But generally a function should guard its own inputs rather than requiring each caller to sanitize first

@ethouris
Copy link
Copy Markdown
Collaborator

The problem is, you can't do the right checks on the sequence numbers only, without reflecting them through the base sequence numbers in these structures - and unfortunately the receiver buffer and the receiver loss structures are separate.

@cl-ment cl-ment merged commit 2e2ab20 into Haivision:master May 21, 2026
15 checks passed
@cl-ment cl-ment added this to the v1.5.6 milestone May 21, 2026
@cl-ment cl-ment added Type: Bug Indicates an unexpected problem or unintended behavior Type: Maintenance Work required to maintain or clean up the code [core] Area: Changes in SRT library core labels May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[core] Area: Changes in SRT library core Type: Bug Indicates an unexpected problem or unintended behavior Type: Maintenance Work required to maintain or clean up the code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants