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

Unified Diff: net/cookies/cookie_util.cc

Issue 2090713003: Make callers of FromUTC(Local)Exploded in net/ use new time API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make callers of FromUTC(Local)Exploded in net/ use new time API. 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
Index: net/cookies/cookie_util.cc
diff --git a/net/cookies/cookie_util.cc b/net/cookies/cookie_util.cc
index 210b8d479af7bcafc3274746b321a0fc6915d26c..9513dc83a6f2d2f507a29c2ee66961aa393e1fb1 100644
--- a/net/cookies/cookie_util.cc
+++ b/net/cookies/cookie_util.cc
@@ -200,12 +200,14 @@ base::Time ParseCookieTime(const std::string& time_string) {
if (exploded.year >= 0 && exploded.year <= 68)
exploded.year += 2000;
- // If our values are within their correct ranges, we got our time.
if (exploded.day_of_month >= 1 && exploded.day_of_month <= 31 &&
- 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);
+ exploded.month >= 1 && exploded.month <= 12 && exploded.year >= 1601 &&
+ exploded.year <= 30827 && exploded.hour <= 23 && exploded.minute <= 59 &&
+ exploded.second <= 59) {
+ // Time conversion can fail. See comments in base/time.h
+ base::Time out_time;
+ if (base::Time::FromUTCExploded(exploded, &out_time))
+ return out_time;
}
// One of our values was out of expected range. For well-formed input,

Powered by Google App Engine
This is Rietveld 408576698