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. base/
  2. build/
  3. components/
  4. crypto/
  5. dbus/
  6. device/
  7. ipc/
  8. libchrome_tools/
  9. mojo/
  10. soong/
  11. testing/
  12. third_party/
  13. ui/
  14. .gitignore
  15. Android.bp
  16. BUILD.gn
  17. BUILD.IGNORE
  18. MODULE_LICENSE_BSD
  19. NOTICE
  20. OWNERS
  21. PRESUBMIT.cfg
  22. README.md
  23. testrunner.cc
README.md

libchrome

Overview

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

See libchrome.md for more info.