Index: base/time/time_mac.cc |
diff --git a/base/time/time_mac.cc b/base/time/time_mac.cc |
index 5803acd35117c175fc43067ac59ce880ee0197b2..88d2d4c28ee434420efe219c958bcb2fee29eceb 100644 |
--- a/base/time/time_mac.cc |
+++ b/base/time/time_mac.cc |
@@ -190,9 +190,18 @@ bool Time::FromExploded(bool is_local, const Exploded& exploded, Time* time) { |
exploded.millisecond); |
CFAbsoluteTime seconds = absolute_time + kCFAbsoluteTimeIntervalSince1970; |
- base::Time converted_time = |
- Time(static_cast<int64_t>(seconds * kMicrosecondsPerSecond) + |
- kWindowsEpochDeltaMicroseconds); |
+ // CFAbsolutTime is typedef of double. Convert seconds to |
+ // microseconds using this type and then cast to int64_t. If |
+ // it cannot be suited to int64, then fail to avoid overflows. |
+ CFAbsoluteTime microseconds = |
miu
2016/10/18 19:55:13
Even though we know CFAbsoluteTime is a double, it
maksims (do not use this acc)
2016/10/19 16:41:04
Done.
|
+ (seconds * kMicrosecondsPerSecond) + kWindowsEpochDeltaMicroseconds; |
+ if (microseconds > std::numeric_limits<int64_t>::max() || |
+ microseconds < std::numeric_limits<int64_t>::min()) { |
+ *time = Time(0); |
+ return false; |
+ } |
+ |
+ base::Time converted_time = Time(static_cast<int64_t>(microseconds)); |
// If |exploded.day_of_month| is set to 31 |
// on a 28-30 day month, it will return the first day of the next month. |