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

Side by Side Diff: base/time/time.h

Issue 2405453002: Fix Integer-overflow in base::Time::FromExploded. (Closed)
Patch Set: rebased and fixed net unittest Created 4 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « no previous file | base/time/time_mac.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Time represents an absolute point in coordinated universal time (UTC), 5 // Time represents an absolute point in coordinated universal time (UTC),
6 // internally represented as microseconds (s/1,000,000) since the Windows epoch 6 // internally represented as microseconds (s/1,000,000) since the Windows epoch
7 // (1601-01-01 00:00:00 UTC). System-dependent clock interface routines are 7 // (1601-01-01 00:00:00 UTC). System-dependent clock interface routines are
8 // defined in time_PLATFORM.cc. Note that values for Time may skew and jump 8 // defined in time_PLATFORM.cc. Note that values for Time may skew and jump
9 // around as the operating system makes adjustments to synchronize (e.g., with 9 // around as the operating system makes adjustments to synchronize (e.g., with
10 // NTP servers). Thus, client code that uses the Time class must account for 10 // NTP servers). Thus, client code that uses the Time class must account for
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 return time; 538 return time;
539 } 539 }
540 static Time FromLocalExploded(const Exploded& exploded) { 540 static Time FromLocalExploded(const Exploded& exploded) {
541 base::Time time; 541 base::Time time;
542 ignore_result(FromLocalExploded(exploded, &time)); 542 ignore_result(FromLocalExploded(exploded, &time));
543 return time; 543 return time;
544 } 544 }
545 545
546 // Converts an exploded structure representing either the local time or UTC 546 // Converts an exploded structure representing either the local time or UTC
547 // into a Time class. Returns false on a failure when, for example, a day of 547 // into a Time class. Returns false on a failure when, for example, a day of
548 // month is set to 31 on a 28-30 day month. 548 // month is set to 31 on a 28-30 day month. Returns Time(0) on overflow.
549 static bool FromUTCExploded(const Exploded& exploded, 549 static bool FromUTCExploded(const Exploded& exploded,
550 Time* time) WARN_UNUSED_RESULT { 550 Time* time) WARN_UNUSED_RESULT {
551 return FromExploded(false, exploded, time); 551 return FromExploded(false, exploded, time);
552 } 552 }
553 static bool FromLocalExploded(const Exploded& exploded, 553 static bool FromLocalExploded(const Exploded& exploded,
554 Time* time) WARN_UNUSED_RESULT { 554 Time* time) WARN_UNUSED_RESULT {
555 return FromExploded(true, exploded, time); 555 return FromExploded(true, exploded, time);
556 } 556 }
557 557
558 // Converts a string representation of time to a Time object. 558 // Converts a string representation of time to a Time object.
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 static void WaitUntilInitializedWin(); 842 static void WaitUntilInitializedWin();
843 #endif 843 #endif
844 }; 844 };
845 845
846 // For logging use only. 846 // For logging use only.
847 BASE_EXPORT std::ostream& operator<<(std::ostream& os, ThreadTicks time_ticks); 847 BASE_EXPORT std::ostream& operator<<(std::ostream& os, ThreadTicks time_ticks);
848 848
849 } // namespace base 849 } // namespace base
850 850
851 #endif // BASE_TIME_TIME_H_ 851 #endif // BASE_TIME_TIME_H_
OLDNEW
« no previous file with comments | « no previous file | base/time/time_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698