Skip to content

Commit 8657f6d

Browse files
committed
Assert that time_t is 64-bit
1 parent 5b4e770 commit 8657f6d

File tree

1 file changed

+3
-8
lines changed
  • src/native/libs/System.Security.Cryptography.Native

1 file changed

+3
-8
lines changed

src/native/libs/System.Security.Cryptography.Native/pal_x509.c

+3-8
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ c_static_assert(PAL_X509_V_ERR_HOSTNAME_MISMATCH == X509_V_ERR_HOSTNAME_MISMATCH
6767
c_static_assert(PAL_X509_V_ERR_EMAIL_MISMATCH == X509_V_ERR_EMAIL_MISMATCH);
6868
c_static_assert(PAL_X509_V_ERR_IP_ADDRESS_MISMATCH == X509_V_ERR_IP_ADDRESS_MISMATCH);
6969

70+
c_static_assert(sizeof(time_t) == sizeof(int64_t));
71+
7072
EVP_PKEY* CryptoNative_GetX509EvpPublicKey(X509* x509)
7173
{
7274
assert(x509 != NULL);
@@ -1354,14 +1356,7 @@ int32_t CryptoNative_X509DecodeOcspToExpiration(const uint8_t* buf, int32_t len,
13541356
time_t expiration_t = 0;
13551357
X509VerifyStatusCode code = CheckOcspGetExpiry(req, resp, subject, issuers[0], ctx, &canCache, &expiration_t);
13561358

1357-
if (sizeof(time_t) == sizeof(int64_t))
1358-
{
1359-
*expiration = (int64_t)expiration_t;
1360-
}
1361-
else if (sizeof(time_t) == sizeof(int32_t))
1362-
{
1363-
*expiration = (int32_t)expiration_t;
1364-
}
1359+
*expiration = (int64_t)expiration_t;
13651360

13661361
if (code == PAL_X509_V_OK || code == PAL_X509_V_ERR_CERT_REVOKED)
13671362
{

0 commit comments

Comments
 (0)