Skip to content

Commit

Permalink
Improve build error on systems that have a 32-bit time_t (#104368)
Browse files Browse the repository at this point in the history
We now require a 64-bit time_t, even on ARM32. This adds a static_assert to ensure time_t is 64-bit, and if not, produce a compile time error.

This also uses a constant instead of `(time_t)INT_MAX + 1` since, if that overflows, it is UB because time_t is a signed type.

Contributes to #104333
  • Loading branch information
vcsjones authored Jul 4, 2024
1 parent 3bad19f commit 7fae7f8
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,11 @@ void InitializeOpenSSLShim(void)
}

#if defined(TARGET_ARM) && defined(TARGET_LINUX)
c_static_assert_msg(sizeof(time_t) == 8, "Build requires 64-bit time_t.");

// This value will represent a time in year 2038 if 64-bit time is used,
// or 1901 if the lower 32 bits are interpreted as a 32-bit time_t value.
time_t timeVal = (time_t)INT_MAX + 1;
time_t timeVal = (time_t)0x80000000U;
struct tm tmVal = { 0 };

// Detect whether openssl is using 32-bit or 64-bit time_t.
Expand Down

0 comments on commit 7fae7f8

Please sign in to comment.