Commit 0379b611 authored by Josh Nohle's avatar Josh Nohle Committed by Commit Bot

[Nearby] Fix integer overflow in expiration scheduler

Using base::Time::Min() for the overdue private certificate expiration
time resulted in integer overflow because base::Time does not use
clamped arithmetic. See crbug/1127026.

Change-Id: I00a898858bf6d2b97aa6a34a37ca2ee90d2c9836
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2404363
Commit-Queue: Josh Nohle <nohle@chromium.org>
Commit-Queue: Ryan Hansberry <hansberry@chromium.org>
Reviewed-by: default avatarRyan Hansberry <hansberry@chromium.org>
Auto-Submit: Josh Nohle <nohle@chromium.org>
Cr-Commit-Position: refs/heads/master@{#805949}
parent d3904acb
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
#include "chrome/browser/nearby_sharing/scheduling/nearby_share_expiration_scheduler.h" #include "chrome/browser/nearby_sharing/scheduling/nearby_share_expiration_scheduler.h"
#include <algorithm>
#include <utility> #include <utility>
NearbyShareExpirationScheduler::NearbyShareExpirationScheduler( NearbyShareExpirationScheduler::NearbyShareExpirationScheduler(
...@@ -32,5 +31,8 @@ NearbyShareExpirationScheduler::TimeUntilRecurringRequest( ...@@ -32,5 +31,8 @@ NearbyShareExpirationScheduler::TimeUntilRecurringRequest(
if (!expiration_time) if (!expiration_time)
return base::nullopt; return base::nullopt;
return std::max(base::TimeDelta::FromSeconds(0), *expiration_time - now); if (*expiration_time <= now)
return base::TimeDelta::FromSeconds(0);
return *expiration_time - now;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment