Fix the overflow when converting current time to milliseconds on 32bit system

Test: Vts/Cts

Bug: 279998685
Change-Id: If8df10e7bb04527e1d9d18f03439bae4ca8dc8fa
diff --git a/identity/CredentialData.cpp b/identity/CredentialData.cpp
index 1bf1527..803e671 100644
--- a/identity/CredentialData.cpp
+++ b/identity/CredentialData.cpp
@@ -520,8 +520,12 @@
                                           bool allowUsingExpiredKeys) {
     AuthKeyData* candidate = nullptr;
 
-    int64_t nowMilliSeconds =
-        std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()) * 1000;
+    time_t now = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
+    int64_t nowMilliSeconds;
+    if (__builtin_mul_overflow(int64_t(now), int64_t(1000), &nowMilliSeconds)) {
+        LOG(ERROR) << "Overflow converting " << now << " to milliseconds";
+        return nullptr;
+    }
 
     int n = 0;
     for (AuthKeyData& data : authKeyDatas_) {