Skip to content

fix(rtcp,sctp): RFC 3550 compliance and SCTP INIT safety hardening#69

Open
nightness wants to merge 1 commit intowebrtc-rs:masterfrom
Brainwires:fix/rtcp-sctp-correctness
Open

fix(rtcp,sctp): RFC 3550 compliance and SCTP INIT safety hardening#69
nightness wants to merge 1 commit intowebrtc-rs:masterfrom
Brainwires:fix/rtcp-sctp-correctness

Conversation

@nightness
Copy link
Copy Markdown

Summary

rtc-rtcp — RFC 3550 §6.4.1 compliance

ReceptionReport::total_lost was u32 but the field is defined by RFC 3550 as a signed 24-bit integer. Negative values occur when duplicate packets arrive (received > expected). This change:

  • Changes the field type to i32
  • Updates serialisation to validate against the signed 24-bit range and write two's-complement bytes
  • Updates deserialisation to sign-extend from bit 23

rtc-sctp — SCTP INIT tag guard

handle_first_packet had a guard on line 214 that checked initiate_tag.is_none() before reaching the .unwrap() on line 239, but the compiler could not verify the coupling. Replaces the unwrap with a let Some(...) else { return None } guard directly at the use site — self-documenting and compiler-verified.

Test Plan

  • cargo build -p rtc-rtcp -p rtc-sctp passes
  • cargo test -p rtc-rtcp — 52 tests pass

🤖 Generated with Claude Code

rtc-rtcp: Change ReceptionReport::total_lost from u32 to i32 (RFC 3550
§6.4.1).  The field is a signed 24-bit integer; negative values occur
when duplicate packets cause received > expected.  Deserialization now
sign-extends from bit 23; serialisation validates against the signed
24-bit range (-8 388 608..=8 388 607).

rtc-sctp: Replace `initiate_tag.as_ref().unwrap()` with a compiler-
verified `let Some(...) else { return None }` guard.  The unwrap was
technically safe due to an earlier check on line 214, but that coupling
was invisible to the compiler.  The new guard is self-documenting and
eliminates the brittle dependency.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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