summaryrefslogtreecommitdiff
path: root/libchrome_tools/patches/libchrome-fix-integer-overflow-if-microseconds-is-IN.patch
blob: a1241b11df9ddae0266e5cda1b992b57726b25ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
From f7ef75a1ddea9d18e1f166b76e90f948cbfd1f77 Mon Sep 17 00:00:00 2001
From: Qijiang Fan <fqj@chromium.org>
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