From f7ef75a1ddea9d18e1f166b76e90f948cbfd1f77 Mon Sep 17 00:00:00 2001 From: Qijiang Fan Date: Tue, 31 Mar 2020 17:43:16 +0900 Subject: [PATCH] libchrome: fix integer overflow if microseconds is INT64_MIN Change-Id: Id3641f6b625f716ae6d134002c0224ed32284939 --- base/time/time_exploded_posix.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/base/time/time_exploded_posix.cc b/base/time/time_exploded_posix.cc index 627c6b4f8735..2aef3864554e 100644 --- a/base/time/time_exploded_posix.cc +++ b/base/time/time_exploded_posix.cc @@ -141,8 +141,7 @@ void Time::Explode(bool is_local, Exploded* exploded) const { millisecond = milliseconds % kMillisecondsPerSecond; } else { // Round these *down* (towards -infinity). - milliseconds = (microseconds - kMicrosecondsPerMillisecond + 1) / - kMicrosecondsPerMillisecond; + milliseconds = (microseconds + 1) / kMicrosecondsPerMillisecond - 1; seconds = (milliseconds - kMillisecondsPerSecond + 1) / kMillisecondsPerSecond; // Make this nonnegative (and between 0 and 999 inclusive). -- 2.24.1