Skip to content

fix(interceptor): clamp total_lost to signed 24-bit max per RFC 3550#77

Open
nightness wants to merge 1 commit intowebrtc-rs:masterfrom
Brainwires:fix/interceptor-total-lost
Open

fix(interceptor): clamp total_lost to signed 24-bit max per RFC 3550#77
nightness wants to merge 1 commit intowebrtc-rs:masterfrom
Brainwires:fix/interceptor-total-lost

Conversation

@nightness
Copy link
Copy Markdown

@nightness nightness commented Apr 1, 2026

Summary

  • receiver_stream.rs: fix the total_lost clamp from 0xFFFFFF (unsigned 24-bit max = 16,777,215) to 0x7FFFFF (signed 24-bit positive max = 8,388,607).

RFC 3550 §6.4.1 defines total_lost as a 24-bit signed integer. The RTCP reception report structure marshals it as a signed value (see rtc-rtcp PR #69 which adds the > 0x7F_FFFF bounds check). The previous clamp at 0xFFFFFF allowed values between 0x800000 and 0xFFFFFF to pass, which are in-range for unsigned 24-bit but out-of-range for signed 24-bit — those values would fail or produce incorrect RTCP reports.

Test plan

  • Existing receiver report tests pass
  • High-loss scenarios: total_lost is clamped at 8,388,607 rather than wrapping or failing RTCP serialization

@nightness nightness force-pushed the fix/interceptor-total-lost branch 2 times, most recently from 55726d4 to 7267904 Compare April 1, 2026 19:03
RFC 3550 §6.4.1 defines total_lost as a 24-bit signed integer. The
previous clamp used 0xFFFFFF (unsigned 24-bit max = 16,777,215) which
allowed values that overflow the signed 24-bit range. Fix the clamp to
0x7FFFFF (signed 24-bit positive max = 8,388,607) so values are always
representable in the reception report field.
@nightness nightness force-pushed the fix/interceptor-total-lost branch from 7267904 to 65f0c5d Compare April 1, 2026 19:03
@nightness nightness changed the title fix(interceptor): cast total_lost to i32 for RFC 3550 compliance fix(interceptor): clamp total_lost to signed 24-bit max per RFC 3550 Apr 1, 2026
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.

1 participant