From 4b0ac5a12b95afbb47a7c41b33b3e8785c9f21a4 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Tue, 14 Jan 2025 10:48:59 +1100 Subject: [PATCH] MDEV-35838 libressl support differences in CRYPTO_set_mem_functions Based on FreeBSD patch. The FreeBSD inclusion of check_openssl_compatibility prevented any use of the crypto callbacks and as such the later differences where ignored. The later differences in coc_malloc didn't propegate to the other callback functions of CRYPTO_set_mem_functions where a reduced argument list also applied. Looking where[2] libressl added the functions it was of the same prototype 10 years ago so omitting any version check. [1] https://github.com/freebsd/freebsd-ports/blob/a34cf9c2dbf503c8248371ba3bab24f34d2d045d/databases/mariadb106-server/files/patch-mysys__ssl_openssl.c [2] https://github.com/libressl/openbsd/commit/5ebad8aceae77c6da6a1e47c3f7e70e8ffae3dae#diff-7f393e5489e6c5780773408f11ca27d9b3bb8f55b174631a1e9467a1dd3010b9R22 --- mysys_ssl/openssl.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/mysys_ssl/openssl.c b/mysys_ssl/openssl.c index e0271817309..3890e3524be 100644 --- a/mysys_ssl/openssl.c +++ b/mysys_ssl/openssl.c @@ -36,8 +36,12 @@ int check_openssl_compatibility() static uint testing; static size_t alloc_size, alloc_count; -static void *coc_malloc(size_t size, const char *f __attribute__((unused)), - int l __attribute__((unused))) +static void *coc_malloc(size_t size +#ifndef LIBRESSL_VERSION_NUMBER + , const char *f __attribute__((unused)), + int l __attribute__((unused)) +#endif +) { if (unlikely(testing)) { @@ -47,15 +51,22 @@ static void *coc_malloc(size_t size, const char *f __attribute__((unused)), return malloc(size); } -static void *coc_realloc(void *addr, size_t num, - const char *file __attribute__((unused)), - int line __attribute__((unused))) +static void *coc_realloc(void *addr, size_t num +#ifndef LIBRESSL_VERSION_NUMBER + , const char *file __attribute__((unused)), + int line __attribute__((unused)) +#endif +) { return realloc(addr, num); } -static void coc_free(void *addr, const char *file __attribute__((unused)), - int line __attribute__((unused))) +static void coc_free(void *addr +#ifndef LIBRESSL_VERSION_NUMBER + , const char *file __attribute__((unused)), + int line __attribute__((unused)) +#endif +) { free(addr); }