From bb2eb8bdd34b583c9b605376a2bb625090c325cb Mon Sep 17 00:00:00 2001 From: Biswakalyan Bhuyan Date: Thu, 19 Sep 2024 23:52:42 +0530 Subject: fixed: BUF_memdup undefined --- src/openssl.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'src') 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 /* INT_MAX INT_MIN LLONG_MAX LLONG_MIN UCHAR_MAX ULLONG_MAX */ #include /* uintptr_t */ +#include #include /* memset(3) strerror_r(3) */ #include /* INFINITY fabs(3) floor(3) frexp(3) fmod(3) round(3) isfinite(3) */ #include /* 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 -- cgit v1.2.3-59-g8ed1b