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

Unified Diff: base/time/time_unittest.cc

Issue 2405453002: Fix Integer-overflow in base::Time::FromExploded. (Closed)
Patch Set: rebased and fixed net unittest Created 4 years, 2 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 | « base/time/time_posix.cc ('k') | base/time/time_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/time/time_unittest.cc
diff --git a/base/time/time_unittest.cc b/base/time/time_unittest.cc
index 313eaea51f7036605b0d7884f84505a1bababd55..a42d701f25a22d7c596888b5ad496b7851ba631b 100644
--- a/base/time/time_unittest.cc
+++ b/base/time/time_unittest.cc
@@ -54,6 +54,11 @@ TEST(TimeTestOutOfBounds, FromExplodedOutOfBoundsTime) {
{{2016, 10, 0, 25, 7, 47, 234, 0}, false},
// Milliseconds are too large
{{2016, 10, 0, 25, 6, 31, 23, 1643}, false},
+ // Test overflow. Time is valid, but overflow case
+ // results in Time(0).
+ {{9840633, 1, 0, 1, 1, 1, 0, 0}, true},
+ // Underflow will fail as well.
+ {{-9840633, 1, 0, 1, 1, 1, 0, 0}, true},
};
for (const auto& test : kDateTestData) {
« no previous file with comments | « base/time/time_posix.cc ('k') | base/time/time_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698