From 65f0c5dd62b55d41c3ae47b629c5fc6f67fd6fd0 Mon Sep 17 00:00:00 2001 From: nightness Date: Wed, 1 Apr 2026 07:13:32 -0500 Subject: [PATCH] fix(interceptor): clamp total_lost to signed 24-bit max per RFC 3550 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- rtc-interceptor/src/report/receiver_stream.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/rtc-interceptor/src/report/receiver_stream.rs b/rtc-interceptor/src/report/receiver_stream.rs index 578a1cd7..ca8f9728 100644 --- a/rtc-interceptor/src/report/receiver_stream.rs +++ b/rtc-interceptor/src/report/receiver_stream.rs @@ -139,12 +139,12 @@ impl ReceiverStream { self.total_lost += total_lost_since_report; - // allow up to 24 bits - if total_lost_since_report > 0xFFFFFF { - total_lost_since_report = 0xFFFFFF; + // allow up to signed 24 bits (RFC 3550 §6.4.1: total_lost is i32) + if total_lost_since_report > 0x7FFFFF { + total_lost_since_report = 0x7FFFFF; } - if self.total_lost > 0xFFFFFF { - self.total_lost = 0xFFFFFF + if self.total_lost > 0x7FFFFF { + self.total_lost = 0x7FFFFF } // Calculate DLSR (Delay Since Last SR) - RFC 3550