Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(400)

Unified Diff: webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.cc

Issue 2195663002: Add sanity check for arrival timestamps. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Typo Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.cc
diff --git a/webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.cc b/webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.cc
index 194ef56b25ea3e6a28aa6cec4285b84bd540f866..20f3bbed6bad62531199c2e5e953c48fffe74c97 100644
--- a/webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.cc
+++ b/webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.cc
@@ -10,6 +10,8 @@
#include "webrtc/modules/remote_bitrate_estimator/remote_estimator_proxy.h"
+#include <limits>
+
#include "webrtc/base/checks.h"
#include "webrtc/base/logging.h"
#include "webrtc/system_wrappers/include/clock.h"
@@ -23,6 +25,11 @@ namespace webrtc {
const int RemoteEstimatorProxy::kDefaultProcessIntervalMs = 50;
const int RemoteEstimatorProxy::kBackWindowMs = 500;
+// The maximum allowed value for a timestamp in milliseconds. This is lower
+// than the numerical limit since we often convert to microseconds.
+static constexpr int64_t kMaxTimeMs =
+ std::numeric_limits<int64_t>::max() / 1000;
+
RemoteEstimatorProxy::RemoteEstimatorProxy(Clock* clock,
PacketRouter* packet_router)
: clock_(clock),
@@ -89,6 +96,11 @@ void RemoteEstimatorProxy::Process() {
void RemoteEstimatorProxy::OnPacketArrival(uint16_t sequence_number,
int64_t arrival_time) {
+ if (arrival_time < 0 || arrival_time > kMaxTimeMs) {
+ LOG(LS_WARNING) << "Arrival time out of bounds: " << arrival_time;
+ return;
+ }
+
// TODO(holmer): We should handle a backwards wrap here if the first
// sequence number was small and the new sequence number is large. The
// SequenceNumberUnwrapper doesn't do this, so we should replace this with
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698