diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/openssl.c | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/src/openssl.c b/src/openssl.c index 6f18a8f..dbb235a 100644 --- a/src/openssl.c +++ b/src/openssl.c @@ -31,6 +31,7 @@ #include <limits.h> /* INT_MAX INT_MIN LLONG_MAX LLONG_MIN UCHAR_MAX ULLONG_MAX */ #include <stdint.h> /* uintptr_t */ +#include <stdlib.h> #include <string.h> /* memset(3) strerror_r(3) */ #include <math.h> /* INFINITY fabs(3) floor(3) frexp(3) fmod(3) round(3) isfinite(3) */ #include <time.h> /* struct tm time_t strptime(3) time(2) */ @@ -582,7 +583,7 @@ #endif #ifndef HAVE_X509_STORE_REFERENCES -#define HAVE_X509_STORE_REFERENCES (!OPENSSL_PREREQ(1,1,0) && LIBRESSL_PREREQ(2,0,0)) +#define HAVE_X509_STORE_REFERENCES (!OPENSSL_PREREQ(1,1,0) && !LIBRESSL_PREREQ(2,0,0)) #endif #ifndef HAVE_X509_STORE_UP_REF @@ -1597,13 +1598,24 @@ static void OPENSSL_clear_free(void *str, size_t num) { return; if (num) OPENSSL_cleanse(str, num); - CRYPTO_free(str); + CRYPTO_free(str, __FILE__, __LINE__); } /* CRYPTO_clear_free() */ #endif #if !HAVE_OPENSSL_MEMDUP static void *OPENSSL_memdup(const void *data, size_t siz) { - return BUF_memdup(data, siz); + if (!data || siz == 0) { + return NULL; + } + + // Allocate memory for the copy + void *copy = malloc(siz); + if (!copy) { + return NULL; + } + + memcpy(copy, data, siz); + return copy; } /* OPENSSL_memdup() */ #endif @@ -1986,11 +1998,11 @@ static size_t compat_SSL_SESSION_get_master_key(const SSL_SESSION *session, unsi #define SSL_client_version(...) EXPAND( compat_SSL_client_version(__VA_ARGS__) ) static int compat_SSL_client_version(const SSL *ssl) { - #if LIBRESSL_PREREQ(2,5,2) - return SSL_version(ssl); - #else - return ssl->client_version; - #endif +#if LIBRESSL_PREREQ(2,5,2) + return SSL_version(ssl); +#else + return ssl->client_version; +#endif } /* compat_SSL_client_version() */ #endif |