From 22cf14c47ed5eb89ee8fdd277f081179b3461dea Mon Sep 17 00:00:00 2001 From: Paul Graham Date: Sun, 12 Nov 2017 18:48:51 +0100 Subject: [PATCH 1/7] Fix syntax error --- plugins/pvio/pvio_socket.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/pvio/pvio_socket.c b/plugins/pvio/pvio_socket.c index 737ca15f3..3b80c33f4 100644 --- a/plugins/pvio/pvio_socket.c +++ b/plugins/pvio/pvio_socket.c @@ -127,7 +127,7 @@ struct st_ma_pvio_methods pvio_socket_methods= { #ifndef HAVE_SOCKET_DYNAMIC MARIADB_PVIO_PLUGIN pvio_socket_plugin= #else -MARIADB_PVIO_PLUGIN _mysql_client_plugin_declaration_ +MARIADB_PVIO_PLUGIN _mysql_client_plugin_declaration_= #endif { MARIADB_CLIENT_PVIO_PLUGIN, From d706eaf90ae2cfd26bd04630a4b38e4524acc054 Mon Sep 17 00:00:00 2001 From: Georg Richter Date: Thu, 3 Mar 2022 06:43:21 +0100 Subject: [PATCH 2/7] PR 172 Fix Sigbus when calling mysql_real_connect_start on ARM/MacOS --- include/ma_context.h | 3 --- libmariadb/CMakeLists.txt | 4 ++++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/ma_context.h b/include/ma_context.h index 3a4eb01e1..2cc40d254 100644 --- a/include/ma_context.h +++ b/include/ma_context.h @@ -52,9 +52,6 @@ struct my_context { #ifdef MY_CONTEXT_USE_UCONTEXT -#if defined(__APPLE__) && !defined(_XOPEN_SOURCE) -#define _XOPEN_SOURCE 600 -#endif #include struct my_context { diff --git a/libmariadb/CMakeLists.txt b/libmariadb/CMakeLists.txt index 70e8fa58d..04f720661 100644 --- a/libmariadb/CMakeLists.txt +++ b/libmariadb/CMakeLists.txt @@ -5,6 +5,10 @@ ADD_DEFINITIONS(-D HAVE_COMPRESS) ADD_DEFINITIONS(-D LIBMARIADB) ADD_DEFINITIONS(-D THREAD) +IF(APPLE) + ADD_DEFINITIONS(-D _XOPEN_SOURCE) +ENDIF() + INCLUDE(${CC_SOURCE_DIR}/cmake/sign.cmake) SET(MARIADB_LIB_SYMBOLS From 7b07d27bbeedea9e43d4826b4fb297a43fa04e8d Mon Sep 17 00:00:00 2001 From: Georg Richter Date: Fri, 4 Mar 2022 08:48:42 +0100 Subject: [PATCH 3/7] Android build fix (PR30) Android NDK doesn't support ushort --- cmake/CheckTypes.cmake | 1 + include/ma_config.h.in | 5 +++++ include/ma_global.h | 2 ++ 3 files changed, 8 insertions(+) diff --git a/cmake/CheckTypes.cmake b/cmake/CheckTypes.cmake index 2a47cc0c7..d33b1b390 100644 --- a/cmake/CheckTypes.cmake +++ b/cmake/CheckTypes.cmake @@ -22,6 +22,7 @@ CHECK_TYPE_SIZE(size_t SIZEOF_SIZE_T) SET(CMAKE_EXTRA_INCLUDE_FILES sys/types.h) CHECK_TYPE_SIZE(uchar SIZEOF_UCHAR) CHECK_TYPE_SIZE(uint SIZEOF_UINT) +CHECK_TYPE_SIZE(uint SIZEOF_USHORT) CHECK_TYPE_SIZE(ulong SIZEOF_ULONG) CHECK_TYPE_SIZE(int8 SIZEOF_INT8) CHECK_TYPE_SIZE(uint8 SIZEOF_UINT8) diff --git a/include/ma_config.h.in b/include/ma_config.h.in index d5ef4f660..c5c758dc6 100644 --- a/include/ma_config.h.in +++ b/include/ma_config.h.in @@ -88,6 +88,11 @@ # define HAVE_UINT 1 #endif +#cmakedefine SIZEOF_USHORT @SIZEOF_USHORT@ +#if defined(SIZEOF_USHORT) +# define HAVE_USHORT 1 +#endif + #cmakedefine SIZEOF_ULONG @SIZEOF_ULONG@ #if defined(SIZEOF_ULONG) # define HAVE_ULONG 1 diff --git a/include/ma_global.h b/include/ma_global.h index e8ca7df37..1b7d68378 100644 --- a/include/ma_global.h +++ b/include/ma_global.h @@ -253,6 +253,8 @@ #if defined(__EMX__) || !defined(HAVE_UINT) typedef unsigned int uint; +#endif +#if defined(__EMX__) || !defined(HAVE_USHORT) typedef unsigned short ushort; #endif From f192d3d1bac7e9f225955039051e7d1d6696bb8f Mon Sep 17 00:00:00 2001 From: Georg Richter Date: Tue, 19 Apr 2022 06:27:32 +0200 Subject: [PATCH 4/7] Fix for CONC-588: Free proxy_header (allocated via MARIADB_OPT_PROXY_HEADER option) when closing connection. --- libmariadb/mariadb_lib.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libmariadb/mariadb_lib.c b/libmariadb/mariadb_lib.c index b37cf430c..b3edfe2e2 100644 --- a/libmariadb/mariadb_lib.c +++ b/libmariadb/mariadb_lib.c @@ -1990,6 +1990,7 @@ static void mysql_close_options(MYSQL *mysql) free(mysql->options.extension->tls_version); free(mysql->options.extension->url); free(mysql->options.extension->connection_handler); + free(mysql->options.extension->proxy_header); if(ma_hashtbl_inited(&mysql->options.extension->connect_attrs)) ma_hashtbl_free(&mysql->options.extension->connect_attrs); if (ma_hashtbl_inited(&mysql->options.extension->userdata)) From 41edecfc41bbd313f9d34525c353a64538f5a1e1 Mon Sep 17 00:00:00 2001 From: Georg Richter Date: Wed, 20 Apr 2022 18:18:05 +0200 Subject: [PATCH 5/7] CONC-580: Fix license header --- plugins/auth/ref10/common.h | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/plugins/auth/ref10/common.h b/plugins/auth/ref10/common.h index 4a52f7742..02c21e63c 100644 --- a/plugins/auth/ref10/common.h +++ b/plugins/auth/ref10/common.h @@ -1,18 +1,22 @@ -/* - Copyright (c) 2017, MariaDB - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, +/************************************************************************************ + Copyright (C) 2017-2022 MariaDB Corporation AB + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not see + or write to the Free Software Foundation, Inc., + 51 Franklin St., Fifth Floor, Boston, MA 02110, USA +*************************************************************************************/ - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ #include #include From b973c75c27d92d519a6db8831bea1de3da13bbc8 Mon Sep 17 00:00:00 2001 From: Georg Richter Date: Wed, 20 Apr 2022 18:46:15 +0200 Subject: [PATCH 6/7] CONC-580: Fixed license header Moved ref10/common.h to plugins/auth/ed25519_common.h and fixed license header --- plugins/auth/ed25519.c | 2 +- plugins/auth/{ref10/common.h => ed25519_common.h} | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) rename plugins/auth/{ref10/common.h => ed25519_common.h} (99%) diff --git a/plugins/auth/ed25519.c b/plugins/auth/ed25519.c index 918b8bada..3c064e733 100644 --- a/plugins/auth/ed25519.c +++ b/plugins/auth/ed25519.c @@ -56,7 +56,7 @@ extern BCRYPT_ALG_HANDLE Sha512Prov; #endif #include -#include +#include #include /* function prototypes */ diff --git a/plugins/auth/ref10/common.h b/plugins/auth/ed25519_common.h similarity index 99% rename from plugins/auth/ref10/common.h rename to plugins/auth/ed25519_common.h index 02c21e63c..6d021fa45 100644 --- a/plugins/auth/ref10/common.h +++ b/plugins/auth/ed25519_common.h @@ -17,7 +17,6 @@ 51 Franklin St., Fifth Floor, Boston, MA 02110, USA *************************************************************************************/ - #include #include From 3ce51b0b3eef9580126e1e1e159077c5b7fab970 Mon Sep 17 00:00:00 2001 From: Georg Richter Date: Wed, 20 Apr 2022 18:48:54 +0200 Subject: [PATCH 7/7] Fix for CONC-587: Since alerts may happen after handshake (for example with described test in CONC-587 using TLSv1.3 protocol or by renegotiation) the tls error message needs to be retrieved if error is a protocol error (SSL_ERROR_SSL) and/or if errno was not set. --- libmariadb/mariadb_lib.c | 14 ++++++++++---- libmariadb/secure/openssl.c | 14 ++++++++++++++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/libmariadb/mariadb_lib.c b/libmariadb/mariadb_lib.c index b3edfe2e2..095d1cb59 100644 --- a/libmariadb/mariadb_lib.c +++ b/libmariadb/mariadb_lib.c @@ -202,10 +202,16 @@ ma_net_safe_read(MYSQL *mysql) if (len == packet_error || len == 0) { end_server(mysql); - my_set_error(mysql, net->last_errno == ER_NET_PACKET_TOO_LARGE ? - CR_NET_PACKET_TOO_LARGE: - CR_SERVER_LOST, - SQLSTATE_UNKNOWN, 0, errno); +#ifdef HAVE_TLS + /* don't overwrite possible tls protocol errors */ + if (net->last_errno != CR_SSL_CONNECTION_ERROR) +#endif + { + my_set_error(mysql, net->last_errno == ER_NET_PACKET_TOO_LARGE ? + CR_NET_PACKET_TOO_LARGE: + CR_SERVER_LOST, + SQLSTATE_UNKNOWN, 0, errno); + } return(packet_error); } if (net->read_pos[0] == 255) diff --git a/libmariadb/secure/openssl.c b/libmariadb/secure/openssl.c index 9196a0cb1..5e29ef6f3 100644 --- a/libmariadb/secure/openssl.c +++ b/libmariadb/secure/openssl.c @@ -591,7 +591,14 @@ ssize_t ma_tls_read(MARIADB_TLS *ctls, const uchar* buffer, size_t length) { int error= SSL_get_error((SSL *)ctls->ssl, rc); if (error != SSL_ERROR_WANT_READ) + { + if (error == SSL_ERROR_SSL || errno == 0) + { + MYSQL *mysql= SSL_get_app_data(ctls->ssl); + ma_tls_set_error(mysql); + } return rc; + } if (pvio->methods->wait_io_or_timeout(pvio, TRUE, pvio->mysql->options.read_timeout) < 1) return rc; } @@ -607,7 +614,14 @@ ssize_t ma_tls_write(MARIADB_TLS *ctls, const uchar* buffer, size_t length) { int error= SSL_get_error((SSL *)ctls->ssl, rc); if (error != SSL_ERROR_WANT_WRITE) + { + if (error == SSL_ERROR_SSL || errno == 0) + { + MYSQL *mysql= SSL_get_app_data(ctls->ssl); + ma_tls_set_error(mysql); + } return rc; + } if (pvio->methods->wait_io_or_timeout(pvio, TRUE, pvio->mysql->options.write_timeout) < 1) return rc; }