Skip to content

Commit

Permalink
Assert that time_t is 64-bit
Browse files Browse the repository at this point in the history
  • Loading branch information
jkotas committed Apr 25, 2024
1 parent 5b4e770 commit 8657f6d
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/native/libs/System.Security.Cryptography.Native/pal_x509.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ c_static_assert(PAL_X509_V_ERR_HOSTNAME_MISMATCH == X509_V_ERR_HOSTNAME_MISMATCH
c_static_assert(PAL_X509_V_ERR_EMAIL_MISMATCH == X509_V_ERR_EMAIL_MISMATCH);
c_static_assert(PAL_X509_V_ERR_IP_ADDRESS_MISMATCH == X509_V_ERR_IP_ADDRESS_MISMATCH);

c_static_assert(sizeof(time_t) == sizeof(int64_t));

Check failure on line 70 in src/native/libs/System.Security.Cryptography.Native/pal_x509.c

View check run for this annotation

Azure Pipelines / runtime (Build linux-arm Debug AllSubsets_Mono)

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

src/native/libs/System.Security.Cryptography.Native/pal_x509.c(70,1): error GD8D85BDA: (NETCORE_ENGINEERING_TELEMETRY=Build) static assertion failed due to requirement 'sizeof(long) == sizeof(long long)':

Check failure on line 70 in src/native/libs/System.Security.Cryptography.Native/pal_x509.c

View check run for this annotation

Azure Pipelines / runtime

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

src/native/libs/System.Security.Cryptography.Native/pal_x509.c(70,1): error GD8D85BDA: (NETCORE_ENGINEERING_TELEMETRY=Build) static assertion failed due to requirement 'sizeof(long) == sizeof(long long)':

EVP_PKEY* CryptoNative_GetX509EvpPublicKey(X509* x509)
{
assert(x509 != NULL);
Expand Down Expand Up @@ -1354,14 +1356,7 @@ int32_t CryptoNative_X509DecodeOcspToExpiration(const uint8_t* buf, int32_t len,
time_t expiration_t = 0;
X509VerifyStatusCode code = CheckOcspGetExpiry(req, resp, subject, issuers[0], ctx, &canCache, &expiration_t);

if (sizeof(time_t) == sizeof(int64_t))
{
*expiration = (int64_t)expiration_t;
}
else if (sizeof(time_t) == sizeof(int32_t))
{
*expiration = (int32_t)expiration_t;
}
*expiration = (int64_t)expiration_t;

if (code == PAL_X509_V_OK || code == PAL_X509_V_ERR_CERT_REVOKED)
{
Expand Down

0 comments on commit 8657f6d

Please sign in to comment.