From 2674447d7557f2da6d7083b79c651407cafdc3c1 Mon Sep 17 00:00:00 2001 From: Georg Richter Date: Fri, 5 Jul 2019 11:14:37 +0200 Subject: [PATCH 1/4] Fix short options --- mariadb_config/mariadb_config.c.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mariadb_config/mariadb_config.c.in b/mariadb_config/mariadb_config.c.in index ae68ecba..bdbdfcfd 100644 --- a/mariadb_config/mariadb_config.c.in +++ b/mariadb_config/mariadb_config.c.in @@ -78,7 +78,7 @@ int main(int argc, char **argv) while(1) { int option_index= 0; - c= getopt_long(argc, argv, "abcdefghij", long_options, &option_index); + c= getopt_long(argc, argv, "abcdefghijkl", long_options, &option_index); switch(c) { case 'a': From 0f4891359a2f336698b4da1d2442a2a5e811435d Mon Sep 17 00:00:00 2001 From: Georg Richter Date: Fri, 5 Jul 2019 11:42:12 +0200 Subject: [PATCH 2/4] Fix for CONC-345: heap-use-after-free in client_mpvio_read_packet Kudos to Kentoku Shiba --- plugins/auth/my_auth.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/auth/my_auth.c b/plugins/auth/my_auth.c index 7c84c784..a096e4d2 100644 --- a/plugins/auth/my_auth.c +++ b/plugins/auth/my_auth.c @@ -353,7 +353,9 @@ static int client_mpvio_read_packet(struct st_plugin_vio *mpv, uchar **buf) } /* otherwise read the data */ - pkt_len= ma_net_safe_read(mysql); + if ((pkt_len= ma_net_safe_read(mysql)) == packet_error); + return (int)packet_error; + mpvio->last_read_packet_len= pkt_len; *buf= mysql->net.read_pos; @@ -547,7 +549,8 @@ int run_plugin_auth(MYSQL *mysql, char *data, uint data_len, res= auth_plugin->authenticate_user((struct st_plugin_vio *)&mpvio, mysql); - if (res > CR_OK && mysql->net.read_pos[0] != 254) + if ((res == CR_ERROR && !mysql->net.buff) || + (res > CR_OK && mysql->net.read_pos[0] != 254)) { /* the plugin returned an error. write it down in mysql, From dc0f66f0066e38cd2e98519fe9bbc84b2b5b72bf Mon Sep 17 00:00:00 2001 From: Georg Richter Date: Fri, 5 Jul 2019 14:09:00 +0200 Subject: [PATCH 3/4] Post fix for CONC-345: removed semicolon --- plugins/auth/my_auth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/auth/my_auth.c b/plugins/auth/my_auth.c index a096e4d2..bab6a3c6 100644 --- a/plugins/auth/my_auth.c +++ b/plugins/auth/my_auth.c @@ -353,7 +353,7 @@ static int client_mpvio_read_packet(struct st_plugin_vio *mpv, uchar **buf) } /* otherwise read the data */ - if ((pkt_len= ma_net_safe_read(mysql)) == packet_error); + if ((pkt_len= ma_net_safe_read(mysql)) == packet_error) return (int)packet_error; mpvio->last_read_packet_len= pkt_len; From 77d051e89d0b342333d951e66e53f2aea43f6e36 Mon Sep 17 00:00:00 2001 From: Georg Richter Date: Tue, 16 Jul 2019 08:52:24 +0200 Subject: [PATCH 4/4] Windows build fixes for OpenSSL --- CMakeLists.txt | 6 +++++- include/ma_config.h.in | 1 + libmariadb/secure/openssl.c | 4 ++++ libmariadb/secure/openssl_crypt.c | 1 + unittest/libmariadb/my_test.h | 2 ++ 5 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0f37bb58..2edc9e6a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -279,7 +279,7 @@ IF(WITH_SSL STREQUAL "ON") IF(WIN32) SET(WITH_SSL "SCHANNEL") ELSE() - SET(WITH_SSL "OPENSSL") + SET(WITH_SSL "PENSSL") ENDIF() ENDIF() @@ -292,8 +292,12 @@ IF(NOT WITH_SSL STREQUAL "OFF") ADD_DEFINITIONS(-DHAVE_OPENSSL -DHAVE_TLS) SET(SSL_SOURCES "${CC_SOURCE_DIR}/libmariadb/secure/openssl.c") SET(SSL_LIBRARIES ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY}) + IF(WIN32) + CHECK_INCLUDE_FILES (${OPENSSL_INCLUDE_DIR}/openssl/applink.c HAVE_OPENSSL_APPLINK_C) + ENDIF() INCLUDE_DIRECTORIES(BEFORE ${OPENSSL_INCLUDE_DIR}) + TRY_RUN(LIBRESSL_RESULT HAVE_LIBRESSL ${CMAKE_BINARY_DIR} ${CC_SOURCE_DIR}/cmake/libressl_version.c diff --git a/include/ma_config.h.in b/include/ma_config.h.in index 8f12ee67..8d462e9e 100644 --- a/include/ma_config.h.in +++ b/include/ma_config.h.in @@ -2,6 +2,7 @@ /* * Include file constants (processed in LibmysqlIncludeFiles.txt 1 */ +#cmakedefine HAVE_OPENSSL_APPLINK_C 1 #cmakedefine HAVE_ALLOCA_H 1 #cmakedefine HAVE_BIGENDIAN 1 #cmakedefine HAVE_SETLOCALE 1 diff --git a/libmariadb/secure/openssl.c b/libmariadb/secure/openssl.c index 41d50460..ac982698 100644 --- a/libmariadb/secure/openssl.c +++ b/libmariadb/secure/openssl.c @@ -30,6 +30,10 @@ #include #include +#if defined(_WIN32) && !defined(_OPENSSL_Applink) && defined(HAVE_OPENSSL_APPLINK_C) +#include +#endif + #if OPENSSL_VERSION_NUMBER >= 0x10002000L && !defined(LIBRESSL_VERSION_NUMBER) #include #define HAVE_OPENSSL_CHECK_HOST 1 diff --git a/libmariadb/secure/openssl_crypt.c b/libmariadb/secure/openssl_crypt.c index ff885c59..01d41a90 100644 --- a/libmariadb/secure/openssl_crypt.c +++ b/libmariadb/secure/openssl_crypt.c @@ -16,6 +16,7 @@ or write to the Free Software Foundation, Inc., 51 Franklin St., Fifth Floor, Boston, MA 02110, USA */ +#include #include #include diff --git a/unittest/libmariadb/my_test.h b/unittest/libmariadb/my_test.h index 0aa673cf..feb10400 100644 --- a/unittest/libmariadb/my_test.h +++ b/unittest/libmariadb/my_test.h @@ -34,6 +34,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #ifndef WIN32 #include +#else +#include #endif #ifndef OK