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

Unified Diff: third_party/WebKit/Source/wtf/DateMath.cpp

Issue 2265443002: Fix an overflow in valueAsDate setter of temporal input types. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: accept null Created 4 years, 4 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 | « third_party/WebKit/Source/bindings/tests/results/core/V8TestObject.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/wtf/DateMath.cpp
diff --git a/third_party/WebKit/Source/wtf/DateMath.cpp b/third_party/WebKit/Source/wtf/DateMath.cpp
index c37b1518e05e60b5b14ecfca2c316ce772576e99..6168f3d0a8c339833f96ddfa32f7647583b2626c 100644
--- a/third_party/WebKit/Source/wtf/DateMath.cpp
+++ b/third_party/WebKit/Source/wtf/DateMath.cpp
@@ -99,6 +99,8 @@ static const double hoursPerDay = 24.0;
static const double secondsPerDay = 24.0 * 60.0 * 60.0;
static const double maxUnixTime = 2145859200.0; // 12/31/2037
+static const double kMinimumECMADateInMs = -8640000000000000.0;
+static const double kMaximumECMADateInMs = 8640000000000000.0;
// Day of year for the first day of each month, where index 0 is January, and day 0 is January 1.
// First for non-leap years, then for leap years.
@@ -166,6 +168,9 @@ static void appendTwoDigitNumber(StringBuilder& builder, int number)
int msToYear(double ms)
{
+ DCHECK(std::isfinite(ms));
+ DCHECK_GE(ms, kMinimumECMADateInMs);
+ DCHECK_LE(ms, kMaximumECMADateInMs);
int approxYear = static_cast<int>(floor(ms / (msPerDay * 365.2425)) + 1970);
double msFromApproxYearTo1970 = msPerDay * daysFrom1970ToYear(approxYear);
if (msFromApproxYearTo1970 > ms)
« no previous file with comments | « third_party/WebKit/Source/bindings/tests/results/core/V8TestObject.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698