From 5b99dbeb5eb0559414ad481119565e0de60ea7cb Mon Sep 17 00:00:00 2001 From: Muhammad Moinur Rahman Date: Mon, 7 Jun 2021 03:16:55 -0500 Subject: databases/mysql-connector-c: UNBREAK for 12.X and later MFH: 2021Q2 (buildtime fix) --- databases/mysql-connector-c/Makefile | 10 +-- .../extra-patch-mysys__ssl_my__aes__openssl.cc | 81 ++++++++++++++++++++++ .../files/extra-patch-vio_viosslfactories.c | 43 ++++++++++++ .../files/patch-cmake_install__layout.cmake | 4 +- .../files/patch-libmysql_CMakeLists.txt | 4 +- 5 files changed, 133 insertions(+), 9 deletions(-) create mode 100644 databases/mysql-connector-c/files/extra-patch-mysys__ssl_my__aes__openssl.cc create mode 100644 databases/mysql-connector-c/files/extra-patch-vio_viosslfactories.c (limited to 'databases') diff --git a/databases/mysql-connector-c/Makefile b/databases/mysql-connector-c/Makefile index f14f7a7249cf..31605a38fb0e 100644 --- a/databases/mysql-connector-c/Makefile +++ b/databases/mysql-connector-c/Makefile @@ -13,9 +13,6 @@ COMMENT= MySQL database connector for C LICENSE= GPLv2 LICENSE_FILE= ${WRKSRC}/COPYING -BROKEN_SSL= openssl -BROKEN_SSL_REASON_openssl= variable has incomplete type 'EVP_CIPHER_CTX' (aka 'evp_cipher_ctx_st') - USES= cmake compiler:features mysql ssl CMAKE_ARGS+= -DOPENSSL_INCLUDE_DIR="${OPENSSLINC}" USE_LDCONFIG= ${PREFIX}/lib/${PORTNAME} @@ -28,9 +25,12 @@ PLIST_SUB+= PORTVERSION=${PORTVERSION} CFLAGS+= -march=i586 .endif +.if (${OPSYS} == FreeBSD && ${OSVERSION} > 1200085 && ${SSL_DEFAULT} == base) || ${SSL_DEFAULT} == openssl +EXTRA_PATCHES+= ${FILESDIR}/extra-patch-vio_viosslfactories.c \ + ${FILESDIR}/extra-patch-mysys__ssl_my__aes__openssl.cc +.endif + .if ${SSL_DEFAULT} == base -BROKEN_FreeBSD_12= incomplete definition of type 'struct dh_st' -BROKEN_FreeBSD_13= incomplete definition of type 'struct dh_st' CMAKE_ARGS+= -DWITH_SSL="system" .else CMAKE_ARGS+= -DWITH_SSL="${OPENSSLBASE}" diff --git a/databases/mysql-connector-c/files/extra-patch-mysys__ssl_my__aes__openssl.cc b/databases/mysql-connector-c/files/extra-patch-mysys__ssl_my__aes__openssl.cc new file mode 100644 index 000000000000..66f558b85489 --- /dev/null +++ b/databases/mysql-connector-c/files/extra-patch-mysys__ssl_my__aes__openssl.cc @@ -0,0 +1,81 @@ +--- mysys_ssl/my_aes_openssl.cc.orig 2021-06-07 05:16:32 UTC ++++ mysys_ssl/my_aes_openssl.cc +@@ -122,7 +122,7 @@ int my_aes_encrypt(const unsigned char *source, uint32 + enum my_aes_opmode mode, const unsigned char *iv, + bool padding) + { +- EVP_CIPHER_CTX ctx; ++ EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new(); + const EVP_CIPHER *cipher= aes_evp_type(mode); + int u_len, f_len; + /* The real key to be used for encryption */ +@@ -132,23 +132,23 @@ int my_aes_encrypt(const unsigned char *source, uint32 + if (!cipher || (EVP_CIPHER_iv_length(cipher) > 0 && !iv)) + return MY_AES_BAD_DATA; + +- if (!EVP_EncryptInit(&ctx, cipher, rkey, iv)) ++ if (!EVP_EncryptInit(ctx, cipher, rkey, iv)) + goto aes_error; /* Error */ +- if (!EVP_CIPHER_CTX_set_padding(&ctx, padding)) ++ if (!EVP_CIPHER_CTX_set_padding(ctx, padding)) + goto aes_error; /* Error */ +- if (!EVP_EncryptUpdate(&ctx, dest, &u_len, source, source_length)) ++ if (!EVP_EncryptUpdate(ctx, dest, &u_len, source, source_length)) + goto aes_error; /* Error */ + +- if (!EVP_EncryptFinal(&ctx, dest + u_len, &f_len)) ++ if (!EVP_EncryptFinal(ctx, dest + u_len, &f_len)) + goto aes_error; /* Error */ + +- EVP_CIPHER_CTX_cleanup(&ctx); ++ EVP_CIPHER_CTX_free(ctx); + return u_len + f_len; + + aes_error: + /* need to explicitly clean up the error if we want to ignore it */ + ERR_clear_error(); +- EVP_CIPHER_CTX_cleanup(&ctx); ++ EVP_CIPHER_CTX_free(ctx); + return MY_AES_BAD_DATA; + } + +@@ -159,7 +159,7 @@ int my_aes_decrypt(const unsigned char *source, uint32 + bool padding) + { + +- EVP_CIPHER_CTX ctx; ++ EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new(); + const EVP_CIPHER *cipher= aes_evp_type(mode); + int u_len, f_len; + +@@ -170,24 +170,22 @@ int my_aes_decrypt(const unsigned char *source, uint32 + if (!cipher || (EVP_CIPHER_iv_length(cipher) > 0 && !iv)) + return MY_AES_BAD_DATA; + +- EVP_CIPHER_CTX_init(&ctx); +- +- if (!EVP_DecryptInit(&ctx, aes_evp_type(mode), rkey, iv)) ++ if (!EVP_DecryptInit(ctx, aes_evp_type(mode), rkey, iv)) + goto aes_error; /* Error */ +- if (!EVP_CIPHER_CTX_set_padding(&ctx, padding)) ++ if (!EVP_CIPHER_CTX_set_padding(ctx, padding)) + goto aes_error; /* Error */ +- if (!EVP_DecryptUpdate(&ctx, dest, &u_len, source, source_length)) ++ if (!EVP_DecryptUpdate(ctx, dest, &u_len, source, source_length)) + goto aes_error; /* Error */ +- if (!EVP_DecryptFinal_ex(&ctx, dest + u_len, &f_len)) ++ if (!EVP_DecryptFinal_ex(ctx, dest + u_len, &f_len)) + goto aes_error; /* Error */ + +- EVP_CIPHER_CTX_cleanup(&ctx); ++ EVP_CIPHER_CTX_free(ctx); + return u_len + f_len; + + aes_error: + /* need to explicitly clean up the error if we want to ignore it */ + ERR_clear_error(); +- EVP_CIPHER_CTX_cleanup(&ctx); ++ EVP_CIPHER_CTX_free(ctx); + return MY_AES_BAD_DATA; + } + diff --git a/databases/mysql-connector-c/files/extra-patch-vio_viosslfactories.c b/databases/mysql-connector-c/files/extra-patch-vio_viosslfactories.c new file mode 100644 index 000000000000..eebe158a1ea2 --- /dev/null +++ b/databases/mysql-connector-c/files/extra-patch-vio_viosslfactories.c @@ -0,0 +1,43 @@ +--- vio/viosslfactories.c.orig 2021-06-07 04:55:13 UTC ++++ vio/viosslfactories.c +@@ -86,7 +86,7 @@ static my_bool ssl_initialized = FALSE; + mjxx/bg6bOOjpgZapvB6ABWlWmRmAAWFtwIBBQ== + -----END DH PARAMETERS----- + */ +-static unsigned char dh2048_p[]= ++static unsigned char dhp_2048[]= + { + 0x8A, 0x5D, 0xFA, 0xC0, 0x66, 0x76, 0x4E, 0x61, 0xFA, 0xCA, 0xC0, 0x37, + 0x57, 0x5C, 0x6D, 0x3F, 0x83, 0x0A, 0xA1, 0xF5, 0xF1, 0xE6, 0x7F, 0x3C, +@@ -112,20 +112,25 @@ static unsigned char dh2048_p[]= + 0x00, 0x05, 0x85, 0xB7, + }; + +-static unsigned char dh2048_g[]={ ++static unsigned char dhg_2048[]={ + 0x05, + }; + + static DH *get_dh2048(void) + { +- DH *dh; +- if ((dh=DH_new())) ++ DH *dh = DH_new(); ++ BIGNUM *dhp_bn, *dhg_bn; ++ ++ if (dh != NULL) + { +- dh->p=BN_bin2bn(dh2048_p,sizeof(dh2048_p),NULL); +- dh->g=BN_bin2bn(dh2048_g,sizeof(dh2048_g),NULL); +- if (! dh->p || ! dh->g) ++ dhp_bn = BN_bin2bn(dhp_2048, sizeof (dhp_2048), NULL); ++ dhg_bn = BN_bin2bn(dhg_2048, sizeof (dhg_2048), NULL); ++ if (dhp_bn == NULL || dhg_bn == NULL ++ || !DH_set0_pqg(dh, dhp_bn, NULL, dhg_bn)) + { + DH_free(dh); ++ BN_free(dhp_bn); ++ BN_free(dhg_bn); + dh=0; + } + } diff --git a/databases/mysql-connector-c/files/patch-cmake_install__layout.cmake b/databases/mysql-connector-c/files/patch-cmake_install__layout.cmake index 890cb1100937..7c5b85dd66fd 100644 --- a/databases/mysql-connector-c/files/patch-cmake_install__layout.cmake +++ b/databases/mysql-connector-c/files/patch-cmake_install__layout.cmake @@ -1,6 +1,6 @@ ---- cmake/install_layout.cmake.orig 2015-02-25 21:09:49 UTC +--- cmake/install_layout.cmake.orig 2017-07-13 06:55:32 UTC +++ cmake/install_layout.cmake -@@ -112,14 +112,14 @@ FILE(GLOB plugin_tests +@@ -151,14 +151,14 @@ SET(secure_file_priv_embedded_path "NULL") # # STANDALONE layout # diff --git a/databases/mysql-connector-c/files/patch-libmysql_CMakeLists.txt b/databases/mysql-connector-c/files/patch-libmysql_CMakeLists.txt index 5575e89f24c2..47298d663ac2 100644 --- a/databases/mysql-connector-c/files/patch-libmysql_CMakeLists.txt +++ b/databases/mysql-connector-c/files/patch-libmysql_CMakeLists.txt @@ -1,6 +1,6 @@ ---- libmysql/CMakeLists.txt.orig 2015-02-25 21:09:49 UTC +--- libmysql/CMakeLists.txt.orig 2017-07-13 06:55:32 UTC +++ libmysql/CMakeLists.txt -@@ -254,7 +254,7 @@ IF(NOT DISABLE_SHARED) +@@ -287,7 +287,7 @@ IF(NOT DISABLE_SHARED) COMPONENT SharedLibraries) IF(UNIX) # libtool compatability -- cgit v1.2.3