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

Unified Diff: net/cookies/cookie_util.cc

Issue 2392873002: Use largest supported date for cookies if timegm overflows
Patch Set: 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') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/cookies/cookie_util.cc
diff --git a/net/cookies/cookie_util.cc b/net/cookies/cookie_util.cc
index 210b8d479af7bcafc3274746b321a0fc6915d26c..5a378064638309e729e685bbdf8532cf38d475b7 100644
--- a/net/cookies/cookie_util.cc
+++ b/net/cookies/cookie_util.cc
@@ -205,7 +205,16 @@ base::Time ParseCookieTime(const std::string& time_string) {
exploded.month >= 1 && exploded.month <= 12 &&
exploded.year >= 1601 && exploded.year <= 30827 &&
exploded.hour <= 23 && exploded.minute <= 59 && exploded.second <= 59) {
- return base::Time::FromUTCExploded(exploded);
+ base::Time time;
+ if (!base::Time::FromUTCExploded(exploded, &time)) {
+ if (exploded.year > 1970) {
+ // Overflow occured in the platform time conversion. Let's
+ // used the largest possible time value.
+ time = base::Time::GetMaxPlatformTime();
+ LOG(WARNING) << "Parsed cookie time was clamped to " << time;
+ }
+ }
+ return time;
}
// One of our values was out of expected range. For well-formed input,
« no previous file with comments | « base/time/time_posix.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698