From b7c15706de3dbee843da7e73d33caacc76fa8589 Mon Sep 17 00:00:00 2001 From: Evan Shrubsole Date: Tue, 29 Mar 2022 12:15:01 +0200 Subject: [PATCH] Fix integer-overflow in TimestampExtrapolator The Frequency implementation does not allow for nominators as large as those that can occur in consecutive RTP timestamps, so use double math instead. Bug: chromium:1310611 Change-Id: I3b239e1b84043470ca29da06728b42cd4552300f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256978 Reviewed-by: Stefan Holmer Commit-Queue: Evan Shrubsole Cr-Commit-Position: refs/heads/main@{#36368} --- rtc_base/time/BUILD.gn | 1 - rtc_base/time/timestamp_extrapolator.cc | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/rtc_base/time/BUILD.gn b/rtc_base/time/BUILD.gn index 092abd9a83..bac649e1d7 100644 --- a/rtc_base/time/BUILD.gn +++ b/rtc_base/time/BUILD.gn @@ -18,7 +18,6 @@ rtc_library("timestamp_extrapolator") { "timestamp_extrapolator.h", ] deps = [ - "../../api/units:frequency", "../../api/units:timestamp", "../../modules:module_api_public", ] diff --git a/rtc_base/time/timestamp_extrapolator.cc b/rtc_base/time/timestamp_extrapolator.cc index 910db8a390..4f8fe0a914 100644 --- a/rtc_base/time/timestamp_extrapolator.cc +++ b/rtc_base/time/timestamp_extrapolator.cc @@ -13,7 +13,6 @@ #include #include "absl/types/optional.h" -#include "api/units/frequency.h" #include "modules/include/module_common_types_public.h" namespace webrtc { @@ -130,8 +129,9 @@ absl::optional TimestampExtrapolator::ExtrapolateLocalTime( if (!first_unwrapped_timestamp_) { return absl::nullopt; } else if (packet_count_ < kStartUpFilterDelayInPackets) { - constexpr Frequency k90KHz = Frequency::KiloHertz(90); - TimeDelta diff = (unwrapped_ts90khz - *prev_unwrapped_timestamp_) / k90KHz; + constexpr double kRtpTicksPerMs = 90; + TimeDelta diff = TimeDelta::Millis( + (unwrapped_ts90khz - *prev_unwrapped_timestamp_) / kRtpTicksPerMs); return prev_ + diff; } else if (w_[0] < 1e-3) { return start_;