Skip to content

Commit b9c4d60

Browse files
authored
fix: improve compatibility with old Linux versions (#4027)
1 parent a0208f8 commit b9c4d60

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

crypto/s2n_openssl_x509.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ S2N_CLEANUP_RESULT s2n_openssl_x509_stack_pop_free(STACK_OF(X509) **cert_chain)
2525
return S2N_RESULT_OK;
2626
}
2727

28-
S2N_CLEANUP_RESULT s2n_openssl_asn1_time_free_pointer(ASN1_GENERALIZEDTIME **time)
28+
S2N_CLEANUP_RESULT s2n_openssl_asn1_time_free_pointer(ASN1_GENERALIZEDTIME **time_ptr)
2929
{
3030
/* The ANS1_*TIME structs are just typedef wrappers around ASN1_STRING
3131
*
@@ -34,8 +34,8 @@ S2N_CLEANUP_RESULT s2n_openssl_asn1_time_free_pointer(ASN1_GENERALIZEDTIME **tim
3434
* ASN1_STRING_free().
3535
* https://www.openssl.org/docs/man1.1.1/man3/ASN1_TIME_to_tm.html
3636
*/
37-
RESULT_ENSURE_REF(*time);
38-
ASN1_STRING_free((ASN1_STRING *) *time);
39-
*time = NULL;
37+
RESULT_ENSURE_REF(*time_ptr);
38+
ASN1_STRING_free((ASN1_STRING *) *time_ptr);
39+
*time_ptr = NULL;
4040
return S2N_RESULT_OK;
4141
}

utils/s2n_random.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@
7272

7373
#define ENTROPY_SOURCE "/dev/urandom"
7474

75+
#if defined(O_CLOEXEC)
76+
#define ENTROPY_FLAGS O_RDONLY | O_CLOEXEC
77+
#else
78+
#define ENTROPY_FLAGS O_RDONLY
79+
#endif
80+
7581
/* See https://en.wikipedia.org/wiki/CPUID */
7682
#define RDRAND_ECX_FLAG 0x40000000
7783

@@ -429,7 +435,7 @@ RAND_METHOD s2n_openssl_rand_method = {
429435
static int s2n_rand_init_impl(void)
430436
{
431437
OPEN:
432-
entropy_fd = open(ENTROPY_SOURCE, O_RDONLY | O_CLOEXEC);
438+
entropy_fd = open(ENTROPY_SOURCE, ENTROPY_FLAGS);
433439
if (entropy_fd == -1) {
434440
if (errno == EINTR) {
435441
goto OPEN;

0 commit comments

Comments
 (0)