Skip to content

Commit

Permalink
fix: improve compatibility with old Linux versions (#4027)
Browse files Browse the repository at this point in the history
  • Loading branch information
camshaft authored May 31, 2023
1 parent a0208f8 commit b9c4d60
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
8 changes: 4 additions & 4 deletions crypto/s2n_openssl_x509.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ S2N_CLEANUP_RESULT s2n_openssl_x509_stack_pop_free(STACK_OF(X509) **cert_chain)
return S2N_RESULT_OK;
}

S2N_CLEANUP_RESULT s2n_openssl_asn1_time_free_pointer(ASN1_GENERALIZEDTIME **time)
S2N_CLEANUP_RESULT s2n_openssl_asn1_time_free_pointer(ASN1_GENERALIZEDTIME **time_ptr)
{
/* The ANS1_*TIME structs are just typedef wrappers around ASN1_STRING
*
Expand All @@ -34,8 +34,8 @@ S2N_CLEANUP_RESULT s2n_openssl_asn1_time_free_pointer(ASN1_GENERALIZEDTIME **tim
* ASN1_STRING_free().
* https://www.openssl.org/docs/man1.1.1/man3/ASN1_TIME_to_tm.html
*/
RESULT_ENSURE_REF(*time);
ASN1_STRING_free((ASN1_STRING *) *time);
*time = NULL;
RESULT_ENSURE_REF(*time_ptr);
ASN1_STRING_free((ASN1_STRING *) *time_ptr);
*time_ptr = NULL;
return S2N_RESULT_OK;
}
8 changes: 7 additions & 1 deletion utils/s2n_random.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@

#define ENTROPY_SOURCE "/dev/urandom"

#if defined(O_CLOEXEC)
#define ENTROPY_FLAGS O_RDONLY | O_CLOEXEC
#else
#define ENTROPY_FLAGS O_RDONLY
#endif

/* See https://en.wikipedia.org/wiki/CPUID */
#define RDRAND_ECX_FLAG 0x40000000

Expand Down Expand Up @@ -429,7 +435,7 @@ RAND_METHOD s2n_openssl_rand_method = {
static int s2n_rand_init_impl(void)
{
OPEN:
entropy_fd = open(ENTROPY_SOURCE, O_RDONLY | O_CLOEXEC);
entropy_fd = open(ENTROPY_SOURCE, ENTROPY_FLAGS);
if (entropy_fd == -1) {
if (errno == EINTR) {
goto OPEN;
Expand Down

0 comments on commit b9c4d60

Please sign in to comment.