base: ClampSub when convert from Windows epoch to UNIX epoch.

In edge cases, When Time::FromTimeT is created with any number smaller
than std::numeric_limit<time_t>::min() / 1000, Time internally saves
us_ as std::numeric_limit<time_t>::min().

When converting back to UNIX epoch (microseconds based), it may overflow
to large intergers.

Use ClampSub to keep it as std::numeric_limit<time_t>::min().

BUG=chromium:1095771, chromium:1054279
TEST=CrashCommonUtilTest.IsOsTimestampTooOldForUploads with ubsan

Change-Id: Ia93e99fcf78c6316c866a946d8b5716cacec09ec
Reviewed-on: https://chromium-review.googlesource.com/c/aosp/platform/external/libchrome/+/2249219
Reviewed-by: Manoj Gupta <manojgupta@chromium.org>
Reviewed-by: Hidehiko Abe <hidehiko@chromium.org>
Commit-Queue: Qijiang Fan <fqj@google.com>
Commit-Queue: Manoj Gupta <manojgupta@chromium.org>
Tested-by: Qijiang Fan <fqj@google.com>
1 file changed
tree: 1dd4ccfffcdd51bb27871accfe6eb219d88a6eb9
  1. .gitignore
  2. Android.bp
  3. BUILD.IGNORE
  4. BUILD.gn
  5. MODULE_LICENSE_BSD
  6. NOTICE
  7. OWNERS
  8. PRESUBMIT.cfg
  9. README.md
  10. base/
  11. build/
  12. components/
  13. crypto/
  14. dbus/
  15. device/
  16. ipc/
  17. libchrome_tools/
  18. mojo/
  19. soong/
  20. testing/
  21. testrunner.cc
  22. third_party/
  23. ui/
README.md

libchrome

Overview

This directory includes the source from Chrome's libbase for use in Chrome OS.

See libchrome.md for more info.