diff --git a/cmake/CheckTypes.cmake b/cmake/CheckTypes.cmake index 02d05b56..3ecedb15 100644 --- a/cmake/CheckTypes.cmake +++ b/cmake/CheckTypes.cmake @@ -21,6 +21,7 @@ SET(CMAKE_EXTRA_INCLUDE_FILES stdio.h) CHECK_TYPE_SIZE(size_t SIZEOF_SIZE_T) SET(CMAKE_EXTRA_INCLUDE_FILES sys/types.h) 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 d5ef4f66..c5c758dc 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_context.h b/include/ma_context.h index 3a4eb01e..2cc40d25 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/include/ma_global.h b/include/ma_global.h index c6a08db6..d6077f31 100644 --- a/include/ma_global.h +++ b/include/ma_global.h @@ -254,6 +254,8 @@ #if defined(__EMX__) || !defined(HAVE_UINT) typedef unsigned int uint; +#endif +#if defined(__EMX__) || !defined(HAVE_USHORT) typedef unsigned short ushort; #endif diff --git a/libmariadb/CMakeLists.txt b/libmariadb/CMakeLists.txt index 55134645..8b98dfa0 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 diff --git a/libmariadb/mariadb_lib.c b/libmariadb/mariadb_lib.c index c98ea1f0..3cf71107 100644 --- a/libmariadb/mariadb_lib.c +++ b/libmariadb/mariadb_lib.c @@ -205,10 +205,16 @@ restart: 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) @@ -2256,6 +2262,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)) diff --git a/libmariadb/secure/openssl.c b/libmariadb/secure/openssl.c index 1d4ee518..2d09821e 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; } diff --git a/plugins/auth/ed25519.c b/plugins/auth/ed25519.c index 399e0385..e0b9333e 100644 --- a/plugins/auth/ed25519.c +++ b/plugins/auth/ed25519.c @@ -55,7 +55,7 @@ extern BCRYPT_ALG_HANDLE Sha512Prov; #endif #include -#include +#include #include /* function prototypes */ diff --git a/plugins/auth/ed25519_common.h b/plugins/auth/ed25519_common.h new file mode 100644 index 00000000..6d021fa4 --- /dev/null +++ b/plugins/auth/ed25519_common.h @@ -0,0 +1,26 @@ +/************************************************************************************ + 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 + 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 +*************************************************************************************/ + +#include +#include + +#include "ref10/api.h" +#include "crypto_sign.h" + +#define NONCE_BYTES 32 diff --git a/plugins/auth/ref10/common.h b/plugins/auth/ref10/common.h deleted file mode 100644 index 4a52f774..00000000 --- a/plugins/auth/ref10/common.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - 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, - 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. - - 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 - -#include "ref10/api.h" -#include "crypto_sign.h" - -#define NONCE_BYTES 32 diff --git a/plugins/pvio/pvio_socket.c b/plugins/pvio/pvio_socket.c index 225f3bea..c4ca16c2 100644 --- a/plugins/pvio/pvio_socket.c +++ b/plugins/pvio/pvio_socket.c @@ -140,7 +140,7 @@ struct st_ma_pvio_methods pvio_socket_methods= { #ifndef PLUGIN_DYNAMIC MARIADB_PVIO_PLUGIN pvio_socket_client_plugin= #else -MARIADB_PVIO_PLUGIN _mysql_client_plugin_declaration_ +MARIADB_PVIO_PLUGIN _mysql_client_plugin_declaration_= #endif { MARIADB_CLIENT_PVIO_PLUGIN,