Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package mariadb-connector-c for openSUSE:Factory checked in at 2023-12-05 17:01:22 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/mariadb-connector-c (Old) and /work/SRC/openSUSE:Factory/.mariadb-connector-c.new.25432 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "mariadb-connector-c" Tue Dec 5 17:01:22 2023 rev:44 rq:1130804 version:3.3.8 Changes: -------- --- /work/SRC/openSUSE:Factory/mariadb-connector-c/mariadb-connector-c.changes 2023-11-22 18:54:18.642920150 +0100 +++ /work/SRC/openSUSE:Factory/.mariadb-connector-c.new.25432/mariadb-connector-c.changes 2023-12-05 17:01:39.805713402 +0100 @@ -1,0 +2,6 @@ +Mon Dec 4 10:18:59 UTC 2023 - Danilo Spinella <o...@danyspin97.org> + +- Update to 3.3.8: + * https://mariadb.com/kb/en/mariadb-connector-c-3-3-8-release-notes/ + +------------------------------------------------------------------- Old: ---- mariadb-connector-c-3.3.7-src.tar.gz mariadb-connector-c-3.3.7-src.tar.gz.asc New: ---- mariadb-connector-c-3.3.8-src.tar.gz mariadb-connector-c-3.3.8-src.tar.gz.asc ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ mariadb-connector-c.spec ++++++ --- /var/tmp/diff_new_pack.UspNsL/_old 2023-12-05 17:01:41.237766189 +0100 +++ /var/tmp/diff_new_pack.UspNsL/_new 2023-12-05 17:01:41.241766336 +0100 @@ -25,7 +25,7 @@ %endif %bcond_with sqlite3 Name: mariadb-connector-c -Version: 3.3.7 +Version: 3.3.8 Release: 0 Summary: MariaDB connector in C License: LGPL-2.1-or-later ++++++ mariadb-connector-c-3.3.7-src.tar.gz -> mariadb-connector-c-3.3.8-src.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mariadb-connector-c-3.3.7-src/.travis.yml new/mariadb-connector-c-3.3.8-src/.travis.yml --- old/mariadb-connector-c-3.3.7-src/.travis.yml 2023-09-07 09:36:18.000000000 +0200 +++ new/mariadb-connector-c-3.3.8-src/.travis.yml 2023-11-01 11:28:04.000000000 +0100 @@ -55,6 +55,8 @@ - env: srv=mariadb-es name: "ES latest" if: type = push AND fork = false + - env: server_branch=10.11 + name: "10.11 Server unit testing" - stage: Enterprise env: srv=mariadb-es v=10.4 @@ -69,10 +71,6 @@ name: "ES 23.08" - env: srv=maxscale name: "Maxscale" - - env: srv=skysql - name: "SkySQL" - - env: srv=skysql-ha - name: "SkySQL with replication" - env: srv=xpand name: "Xpand" @@ -80,6 +78,11 @@ env: srv=mariadb v=10.11 os: windows language: shell + name: "Windows" + - env: server_branch=10.6 + name: "10.6 Server unit testing" + - env: server_branch=11.3 TEST_OPTION=--ps-protocol + name: "11.3 Server unit testing with ps-protocol" - env: srv=mariadb v=10.4 local=1 dist: bionic name: "CS 10.4" @@ -92,7 +95,7 @@ name: "CS 10.10" - env: srv=mariadb v=10.11 local=1 name: "CS 10.11" - - env: srv=mariadb v=10.11 local=1 TEST_OPTION=--ps-protocol + - env: srv=mariadb v=10.11 local=1 TEST_OPTION=--ps-protocol name: "CS 10.11 with ps-protocol" - env: srv=mariadb v=11.0 local=1 name: "CS 11.0" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mariadb-connector-c-3.3.7-src/CMakeLists.txt new/mariadb-connector-c-3.3.8-src/CMakeLists.txt --- old/mariadb-connector-c-3.3.7-src/CMakeLists.txt 2023-09-07 09:36:18.000000000 +0200 +++ new/mariadb-connector-c-3.3.8-src/CMakeLists.txt 2023-11-01 11:28:04.000000000 +0100 @@ -36,7 +36,7 @@ SET(CPACK_PACKAGE_VERSION_MAJOR 3) SET(CPACK_PACKAGE_VERSION_MINOR 3) -SET(CPACK_PACKAGE_VERSION_PATCH 7) +SET(CPACK_PACKAGE_VERSION_PATCH 8) SET(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") MATH(EXPR MARIADB_PACKAGE_VERSION_ID "${CPACK_PACKAGE_VERSION_MAJOR} * 10000 + ${CPACK_PACKAGE_VERSION_MINOR} * 100 + @@ -133,7 +133,7 @@ IF(CMAKE_COMPILER_IS_GNUCC) INCLUDE(CheckCCompilerFlag) - SET(GCC_FLAGS -Wunused -Wlogical-op -Wno-uninitialized -Wall -Wextra -Wformat-security -Wno-init-self -Wwrite-strings -Wshift-count-overflow -Wdeclaration-after-statement -Wno-undef -Wno-unknown-pragmas) + SET(GCC_FLAGS -Wunused -Wlogical-op -Wno-uninitialized -Wall -Wextra -Wformat-security -Wno-init-self -Wwrite-strings -Wshift-count-overflow -Wdeclaration-after-statement -Wno-undef -Wno-unknown-pragmas -Wno-stringop-truncation) FOREACH(GCC_FLAG ${GCC_FLAGS}) CHECK_C_COMPILER_FLAG("${GCC_FLAG}" HAS_${GCC_FLAG}_FLAG) IF(${HAS_${GCC_FLAG}_FLAG}) @@ -276,10 +276,7 @@ IF(WIN32) SET(HAVE_THREADS 1) ADD_DEFINITIONS(-DHAVE_DLOPEN) - ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS) - IF(MSVC) - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4996" ) - ENDIF() + ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE) ELSEIF() SET(HAVE_THREADS ${CMAKE_USE_PTHREADS}) ENDIF() @@ -398,12 +395,14 @@ MESSAGE1(SYSTEM_LIBS "SYSTEM_LIBS ${SYSTEM_LIBS}") MARK_AS_ADVANCED(SYSTEM_LIBS) -IF (CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_C_COMPILER_ID MATCHES "GNU") - SET(WARNING_AS_ERROR "-Werror" CACHE INTERNAL "WARNING_AS_ERROR") +IF(NOT IS_SUBPROJECT) +IF ((NOT WIN32) AND (CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_C_COMPILER_ID MATCHES "GNU")) + SET(WARNING_AS_ERROR "-Werror") ELSEIF(CMAKE_C_COMPILER_ID MATCHES "MSVC") - SET(WARNING_AS_ERROR "/WX" CACHE INTERNAL "WARNING_AS_ERROR") + SET(WARNING_AS_ERROR "/WX") ENDIF() SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_AS_ERROR}") +ENDIF() IF(NOT REMOTEIO_PLUGIN_TYPE MATCHES "OFF") @@ -429,7 +428,7 @@ INCLUDE(${CC_SOURCE_DIR}/plugins/CMakeLists.txt) ADD_SUBDIRECTORY(include) ADD_SUBDIRECTORY(libmariadb) -IF(NOT MSVC) +IF((NOT WIN32) OR CYGWIN) ADD_SUBDIRECTORY(mariadb_config) ENDIF() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mariadb-connector-c-3.3.7-src/cmake/WindowsCache.cmake new/mariadb-connector-c-3.3.8-src/cmake/WindowsCache.cmake --- old/mariadb-connector-c-3.3.7-src/cmake/WindowsCache.cmake 2023-09-07 09:36:18.000000000 +0200 +++ new/mariadb-connector-c-3.3.8-src/cmake/WindowsCache.cmake 2023-11-01 11:28:04.000000000 +0100 @@ -300,8 +300,7 @@ SET(HAVE_VSNPRINTF 1 CACHE INTERNAL "") ENDIF() SET(HAVE_WEAK_SYMBOL CACHE INTERNAL "") -SET(HAVE_WORDS_BIGENDIAN TRUE CACHE INTERNAL "") -SET(WORDS_BIGENDIAN CACHE INTERNAL "") +SET(HAVE_BIGENDIAN CACHE INTERNAL "") SET(HAVE__S_IFIFO 1 CACHE INTERNAL "") SET(HAVE__S_IREAD 1 CACHE INTERNAL "") SET(HAVE__finite 1 CACHE INTERNAL "") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mariadb-connector-c-3.3.7-src/include/ma_crypt.h new/mariadb-connector-c-3.3.8-src/include/ma_crypt.h --- old/mariadb-connector-c-3.3.7-src/include/ma_crypt.h 2023-09-07 09:36:18.000000000 +0200 +++ new/mariadb-connector-c-3.3.8-src/include/ma_crypt.h 2023-11-01 11:28:04.000000000 +0100 @@ -31,6 +31,7 @@ #define MA_HASH_SHA384 5 #define MA_HASH_SHA512 6 #define MA_HASH_RIPEMD160 7 +#define MA_HASH_MAX 8 /*! Hash digest sizes */ #define MA_MD5_HASH_SIZE 16 @@ -45,15 +46,7 @@ /** \typedef MRL hash context */ #if defined(HAVE_WINCRYPT) -#include <windows.h> -#include <bcrypt.h> -typedef struct { - char free_me; - BCRYPT_ALG_HANDLE hAlg; - BCRYPT_HASH_HANDLE hHash; - PBYTE hashObject; - DWORD digest_len; -} MA_HASH_CTX; +typedef void MA_HASH_CTX; #elif defined(HAVE_OPENSSL) #include <openssl/evp.h> typedef EVP_MD_CTX MA_HASH_CTX; @@ -68,11 +61,10 @@ @brief acquire and initialize new hash context @param[in] algorithm hash algorithm - @param[in] ctx pointer to a crypto context @return hash context on success, NULL on error */ -MA_HASH_CTX *ma_hash_new(unsigned int algorithm, MA_HASH_CTX *ctx); +MA_HASH_CTX *ma_hash_new(unsigned int algorithm); /** @brief release and deinitializes a hash context @@ -154,11 +146,7 @@ unsigned char *digest) { MA_HASH_CTX *ctx= NULL; -#ifdef HAVE_WINCRYPT - MA_HASH_CTX dctx; - ctx= &dctx; -#endif - ctx= ma_hash_new(algorithm, ctx); + ctx= ma_hash_new(algorithm); ma_hash_input(ctx, buffer, buffer_length); ma_hash_result(ctx, digest); ma_hash_free(ctx); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mariadb-connector-c-3.3.7-src/include/ma_global.h new/mariadb-connector-c-3.3.8-src/include/ma_global.h --- old/mariadb-connector-c-3.3.7-src/include/ma_global.h 2023-09-07 09:36:18.000000000 +0200 +++ new/mariadb-connector-c-3.3.8-src/include/ma_global.h 2023-11-01 11:28:04.000000000 +0100 @@ -29,13 +29,7 @@ #define strtok_r strtok_s #define strdup _strdup #define sleep(x) Sleep(1000*(x)) -#ifdef _MSC_VER -#define inline __inline -#if _MSC_VER < 1900 -#define snprintf _snprintf -#endif #define strerror_r(errno,buf,len) strerror_s(buf,len,errno) -#endif #define STDCALL __stdcall #endif @@ -964,7 +958,7 @@ #define float8get(V,M) doubleget((V),(M)) #define float8store(V,M) doublestore((V),(M)) -#endif /* WORDS_BIGENDIAN */ +#endif /* HAVE_BIGENDIAN */ #endif /* __i386__ OR _WIN32 */ @@ -1034,7 +1028,7 @@ #define longlongget(V,M) memcpy(&V, (M), sizeof(ulonglong)) #define longlongstore(T,V) memcpy((T), &V, sizeof(ulonglong)) -#endif /* WORDS_BIGENDIAN */ +#endif /* HAVE_BIGENDIAN */ #ifndef THREAD #define thread_safe_increment(V,L) ((V)++) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mariadb-connector-c-3.3.7-src/libmariadb/ma_alloc.c new/mariadb-connector-c-3.3.8-src/libmariadb/ma_alloc.c --- old/mariadb-connector-c-3.3.7-src/libmariadb/ma_alloc.c 2023-09-07 09:36:18.000000000 +0200 +++ new/mariadb-connector-c-3.3.8-src/libmariadb/ma_alloc.c 2023-11-01 11:28:04.000000000 +0100 @@ -21,13 +21,14 @@ #include <ma_sys.h> #include <ma_string.h> +#define INIT_BLOCK_NUM 4 void ma_init_alloc_root(MA_MEM_ROOT *mem_root, size_t block_size, size_t pre_alloc_size) { mem_root->free= mem_root->used= mem_root->pre_alloc= 0; mem_root->min_malloc=32; mem_root->block_size= (block_size-MALLOC_OVERHEAD-sizeof(MA_USED_MEM)+8); mem_root->error_handler=0; - mem_root->block_num= 4; + mem_root->block_num= INIT_BLOCK_NUM; mem_root->first_block_usage= 0; #if !(defined(HAVE_purify) && defined(EXTRA_DEBUG)) if (pre_alloc_size) @@ -141,6 +142,8 @@ root->free->left=root->pre_alloc->size-ALIGN_SIZE(sizeof(MA_USED_MEM)); root->free->next=0; } + root->block_num= INIT_BLOCK_NUM; + root->first_block_usage= 0; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mariadb-connector-c-3.3.7-src/libmariadb/ma_context.c new/mariadb-connector-c-3.3.8-src/libmariadb/ma_context.c --- old/mariadb-connector-c-3.3.7-src/libmariadb/ma_context.c 2023-09-07 09:36:18.000000000 +0200 +++ new/mariadb-connector-c-3.3.8-src/libmariadb/ma_context.c 2023-11-01 11:28:04.000000000 +0100 @@ -30,6 +30,9 @@ #endif #ifdef MY_CONTEXT_USE_UCONTEXT + +typedef void (*uc_func_t)(void); + /* The makecontext() only allows to pass integers into the created context :-( We want to pass pointers, so we do it this kinda hackish way. @@ -47,8 +50,7 @@ the actual type (as the actual type can differ from call to call). */ static void -my_context_spawn_internal(i0, i1) -int i0, i1; +my_context_spawn_internal(int i0, int i1) { int err; struct my_context *c; @@ -101,7 +103,7 @@ c->user_data= d; c->active= 1; u.p= c; - makecontext(&c->spawned_context, my_context_spawn_internal, 2, + makecontext(&c->spawned_context, (uc_func_t)my_context_spawn_internal, 2, u.a[0], u.a[1]); return my_context_continue(c); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mariadb-connector-c-3.3.7-src/libmariadb/ma_dtoa.c new/mariadb-connector-c-3.3.8-src/libmariadb/ma_dtoa.c --- old/mariadb-connector-c-3.3.7-src/libmariadb/ma_dtoa.c 2023-09-07 09:36:18.000000000 +0200 +++ new/mariadb-connector-c-3.3.8-src/libmariadb/ma_dtoa.c 2023-11-01 11:28:04.000000000 +0100 @@ -512,7 +512,7 @@ typedef union { double d; ULong L[2]; } U; -#if defined(HAVE_BIGENDIAN) || defined(WORDS_BIGENDIAN) || \ +#if defined(HAVE_BIGENDIAN) || \ (defined(__FLOAT_WORD_ORDER) && (__FLOAT_WORD_ORDER == __BIG_ENDIAN)) #define word0(x) ((x)->L[0]) #define word1(x) ((x)->L[1]) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mariadb-connector-c-3.3.7-src/libmariadb/ma_net.c new/mariadb-connector-c-3.3.8-src/libmariadb/ma_net.c --- old/mariadb-connector-c-3.3.7-src/libmariadb/ma_net.c 2023-09-07 09:36:18.000000000 +0200 +++ new/mariadb-connector-c-3.3.8-src/libmariadb/ma_net.c 2023-11-01 11:28:04.000000000 +0100 @@ -292,7 +292,7 @@ return 0; } -unsigned char *mysql_net_store_length(unsigned char *packet, size_t length); +unsigned char *mysql_net_store_length(unsigned char *packet, ulonglong length); /* Read and write using timeouts */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mariadb-connector-c-3.3.7-src/libmariadb/mariadb_lib.c new/mariadb-connector-c-3.3.8-src/libmariadb/mariadb_lib.c --- old/mariadb-connector-c-3.3.7-src/libmariadb/mariadb_lib.c 2023-09-07 09:36:18.000000000 +0200 +++ new/mariadb-connector-c-3.3.8-src/libmariadb/mariadb_lib.c 2023-11-01 11:28:04.000000000 +0100 @@ -123,7 +123,7 @@ extern int mthd_stmt_read_all_rows(MYSQL_STMT *stmt); extern void mthd_stmt_flush_unbuffered(MYSQL_STMT *stmt); extern my_bool _mariadb_read_options(MYSQL *mysql, const char *dir, const char *config_file, const char *group, unsigned int recursion); -extern unsigned char *mysql_net_store_length(unsigned char *packet, size_t length); +extern unsigned char *mysql_net_store_length(unsigned char *packet, ulonglong length); extern void my_context_install_suspend_resume_hook(struct mysql_async_context *b, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mariadb-connector-c-3.3.7-src/libmariadb/mariadb_stmt.c new/mariadb-connector-c-3.3.8-src/libmariadb/mariadb_stmt.c --- old/mariadb-connector-c-3.3.7-src/libmariadb/mariadb_stmt.c 2023-09-07 09:36:18.000000000 +0200 +++ new/mariadb-connector-c-3.3.8-src/libmariadb/mariadb_stmt.c 2023-11-01 11:28:04.000000000 +0100 @@ -492,7 +492,7 @@ return(NULL); } -unsigned char *mysql_net_store_length(unsigned char *packet, size_t length) +unsigned char *mysql_net_store_length(unsigned char *packet, ulonglong length) { if (length < (unsigned long long) L64(251)) { *packet = (unsigned char) length; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mariadb-connector-c-3.3.7-src/libmariadb/secure/gnutls_crypt.c new/mariadb-connector-c-3.3.8-src/libmariadb/secure/gnutls_crypt.c --- old/mariadb-connector-c-3.3.7-src/libmariadb/secure/gnutls_crypt.c 2023-09-07 09:36:18.000000000 +0200 +++ new/mariadb-connector-c-3.3.8-src/libmariadb/secure/gnutls_crypt.c 2023-11-01 11:28:04.000000000 +0100 @@ -41,7 +41,7 @@ } } -MA_HASH_CTX *ma_hash_new(unsigned int algorithm, MA_HASH_CTX *unused_ctx __attribute__((unused))) +MA_HASH_CTX *ma_hash_new(unsigned int algorithm) { gnutls_hash_hd_t ctx= NULL; gnutls_digest_algorithm_t hash_alg= ma_hash_get_algorithm(algorithm); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mariadb-connector-c-3.3.7-src/libmariadb/secure/openssl_crypt.c new/mariadb-connector-c-3.3.8-src/libmariadb/secure/openssl_crypt.c --- old/mariadb-connector-c-3.3.7-src/libmariadb/secure/openssl_crypt.c 2023-09-07 09:36:18.000000000 +0200 +++ new/mariadb-connector-c-3.3.8-src/libmariadb/secure/openssl_crypt.c 2023-11-01 11:28:04.000000000 +0100 @@ -43,7 +43,7 @@ } } -MA_HASH_CTX *ma_hash_new(unsigned int algorithm, MA_HASH_CTX *unused __attribute__((unused))) +MA_HASH_CTX *ma_hash_new(unsigned int algorithm) { EVP_MD_CTX *ctx= NULL; const EVP_MD *evp_md= ma_hash_get_algorithm(algorithm); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mariadb-connector-c-3.3.7-src/libmariadb/secure/schannel_certs.c new/mariadb-connector-c-3.3.8-src/libmariadb/secure/schannel_certs.c --- old/mariadb-connector-c-3.3.7-src/libmariadb/secure/schannel_certs.c 2023-09-07 09:36:18.000000000 +0200 +++ new/mariadb-connector-c-3.3.8-src/libmariadb/secure/schannel_certs.c 2023-11-01 11:28:04.000000000 +0100 @@ -32,14 +32,12 @@ #undef _WIN32_WINNT #define _WIN32_WINNT 0x0601 #endif - #include "schannel_certs.h" #include <malloc.h> #include <stdio.h> #include <string.h> -#include <winsock2.h> -#include <ws2tcpip.h> #include <winhttp.h> +#include <limits.h> #include <assert.h> #include "win32_errmsg.h" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mariadb-connector-c-3.3.7-src/libmariadb/secure/win_crypt.c new/mariadb-connector-c-3.3.8-src/libmariadb/secure/win_crypt.c --- old/mariadb-connector-c-3.3.7-src/libmariadb/secure/win_crypt.c 2023-09-07 09:36:18.000000000 +0200 +++ new/mariadb-connector-c-3.3.8-src/libmariadb/secure/win_crypt.c 2023-11-01 11:28:04.000000000 +0100 @@ -20,84 +20,143 @@ #include <bcrypt.h> #include <ma_crypt.h> #include <malloc.h> +#include <stdlib.h> +#include <stdio.h> -BCRYPT_ALG_HANDLE Sha256Prov= 0; -BCRYPT_ALG_HANDLE Sha512Prov= 0; -BCRYPT_ALG_HANDLE RsaProv= 0; +/* + Error handling for bcrypt. + If we can't meaningfully return an error, dump error on stderr + and abort. Those errors are mostly likely programming errors + (invalid parameters and such) +*/ +static inline void check_nt_status(int ret, const char *function, + const char *file, int line) +{ + if (ret) + { + fprintf(stderr,"invalid return %d from bcrypt, " + "function %s with file %s, line %d\n", + ret, function, file, line); + abort(); + } +} +#define CHECK_NT_STATUS(ret) check_nt_status(ret, __func__, __FILE__, __LINE__) -static LPCWSTR ma_hash_get_algorithm(unsigned int alg, BCRYPT_ALG_HANDLE *algHdl) +/* + Return Bcrypt algorithm ID (wchar string) for MariaDB numeric ID +*/ +static LPCWSTR ma_hash_get_algorithm(unsigned int alg) { - switch(alg) + switch (alg) { + case MA_HASH_SHA1: + return BCRYPT_SHA1_ALGORITHM; case MA_HASH_SHA256: - *algHdl= Sha256Prov; return BCRYPT_SHA256_ALGORITHM; + case MA_HASH_SHA384: + return BCRYPT_SHA384_ALGORITHM; case MA_HASH_SHA512: - *algHdl= Sha512Prov; return BCRYPT_SHA512_ALGORITHM; default: - *algHdl= 0; return NULL; } } -MA_HASH_CTX *ma_hash_new(unsigned int algorithm, MA_HASH_CTX *ctx) +/* Cached algorithm provides handles. */ +static BCRYPT_ALG_HANDLE cached_alg_handles[MA_HASH_MAX]; + +/* + Cleanup cached algorithm handles. It runs either on process exit, + or when DLL is unloaded (see _onexit() documentation) +*/ +static int win_crypt_onexit(void) { - MA_HASH_CTX *newctx= ctx; - DWORD cbObjSize, cbData; - LPCWSTR alg; - BCRYPT_ALG_HANDLE algHdl= 0; + int i; + for (i= 0; i < MA_HASH_MAX; i++) + { + if (cached_alg_handles[i]) + BCryptCloseAlgorithmProvider(cached_alg_handles[i], 0); + } + return 0; +} - alg= ma_hash_get_algorithm(algorithm, &algHdl); +static void register_cleanup_onexit_once() +{ + static LONG onexit_called; + if (!InterlockedCompareExchange(&onexit_called, 1, 0)) + _onexit(win_crypt_onexit); +} - if (!alg || !algHdl) - return NULL; +/* + Given algorithm ID, return BCRYPT provider handle. + Uses or populates algorithm provider handle cache. +*/ +static BCRYPT_ALG_HANDLE ma_hash_get_algorithm_handle(unsigned int alg) +{ + static SRWLOCK lock= SRWLOCK_INIT; + BCRYPT_ALG_HANDLE handle= NULL; + const wchar_t *name; - if (BCryptGetProperty(algHdl, BCRYPT_OBJECT_LENGTH, - (PBYTE)&cbObjSize, sizeof(DWORD), - &cbData, 0) < 0) - goto error; + if ((handle= cached_alg_handles[alg]) != NULL) + return handle; - if (!newctx) + name= ma_hash_get_algorithm(alg); + if (!name) + return NULL; + + AcquireSRWLockExclusive(&lock); + if ((handle= cached_alg_handles[alg]) == NULL) { - newctx= (MA_HASH_CTX *)calloc(1, sizeof(MA_HASH_CTX)); - newctx->free_me= 1; + if (BCryptOpenAlgorithmProvider(&handle, name, NULL, 0) == 0) + cached_alg_handles[alg]= handle; + else + handle= NULL; } - else - memset(newctx, 0, sizeof(MA_HASH_CTX)); + ReleaseSRWLockExclusive(&lock); + + if (handle) + register_cleanup_onexit_once(); + return handle; +} + +MA_HASH_CTX *ma_hash_new(unsigned int algorithm) +{ + BCRYPT_HASH_HANDLE hash_handle; + BCRYPT_ALG_HANDLE alg_handle= ma_hash_get_algorithm_handle(algorithm); + + if (!alg_handle) + return NULL; + + if (BCryptCreateHash(alg_handle, &hash_handle, NULL, 0, NULL, 0, 0)) + return NULL; - newctx->hashObject= (PBYTE)malloc(cbObjSize); - newctx->digest_len= (DWORD)ma_hash_digest_size(algorithm); - BCryptCreateHash(algHdl, &newctx->hHash, newctx->hashObject, cbObjSize, NULL, 0, 0); - - return newctx; -error: - if (newctx && !ctx) - free(newctx); - return NULL; + return hash_handle; } void ma_hash_free(MA_HASH_CTX *ctx) { - if (ctx) - { - if (ctx->hHash) - BCryptDestroyHash(ctx->hHash); - if (ctx->hashObject) - free(ctx->hashObject); - if (ctx->free_me) - free(ctx); - } + NTSTATUS status; + if (!ctx) + return; + status= BCryptDestroyHash(ctx); + CHECK_NT_STATUS(status); } -void ma_hash_input(MA_HASH_CTX *ctx, - const unsigned char *buffer, - size_t len) +void ma_hash_input(MA_HASH_CTX *ctx, const unsigned char *buffer, size_t len) { - BCryptHashData(ctx->hHash, (PUCHAR)buffer, (LONG)len, 0); + NTSTATUS status= BCryptHashData(ctx, (PUCHAR) buffer, (ULONG) len, 0); + CHECK_NT_STATUS(status); } void ma_hash_result(MA_HASH_CTX *ctx, unsigned char *digest) { - BCryptFinishHash(ctx->hHash, digest, ctx->digest_len, 0); + DWORD hash_length; + DWORD data_length; + NTSTATUS status= + BCryptGetProperty(ctx, BCRYPT_HASH_LENGTH, (PBYTE) &hash_length, + sizeof(DWORD), &data_length, 0); + CHECK_NT_STATUS(status); + + status= BCryptFinishHash(ctx, digest, (ULONG) hash_length, 0); + CHECK_NT_STATUS(status); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mariadb-connector-c-3.3.7-src/plugins/auth/caching_sha2_pw.c new/mariadb-connector-c-3.3.8-src/plugins/auth/caching_sha2_pw.c --- old/mariadb-connector-c-3.3.7-src/plugins/auth/caching_sha2_pw.c 2023-09-07 09:36:18.000000000 +0200 +++ new/mariadb-connector-c-3.3.8-src/plugins/auth/caching_sha2_pw.c 2023-11-01 11:28:04.000000000 +0100 @@ -52,8 +52,6 @@ #include <wincrypt.h> #include <bcrypt.h> -extern BCRYPT_ALG_HANDLE RsaProv; -extern BCRYPT_ALG_HANDLE Sha256Prov; #endif #include <ma_crypt.h> @@ -84,12 +82,8 @@ unsigned char digest1[MA_SHA256_HASH_SIZE], digest2[MA_SHA256_HASH_SIZE], new_scramble[MA_SHA256_HASH_SIZE]; -#ifdef HAVE_WINCRYPT - MA_HASH_CTX myctx; - MA_HASH_CTX *ctx= &myctx; -#else + MA_HASH_CTX *ctx = NULL; -#endif size_t i; /* check if all specified lengths are valid */ @@ -97,27 +91,22 @@ return 1; /* Step1: create sha256 from source */ - if (!(ctx= ma_hash_new(MA_HASH_SHA256, ctx))) + if (!(ctx= ma_hash_new(MA_HASH_SHA256))) return 1; ma_hash_input(ctx, source, source_len); ma_hash_result(ctx, digest1); ma_hash_free(ctx); -#ifndef HAVE_WINCRYPT - ctx = NULL; -#endif + /* Step2: create sha256 digest from digest1 */ - if (!(ctx= ma_hash_new(MA_HASH_SHA256, ctx))) + if (!(ctx= ma_hash_new(MA_HASH_SHA256))) return 1; ma_hash_input(ctx, digest1, MA_SHA256_HASH_SIZE); ma_hash_result(ctx, digest2); ma_hash_free(ctx); -#ifndef HAVE_WINCRYPT - ctx = NULL; -#endif /* Step3: create sha256 digest from digest2 + salt */ - if (!(ctx= ma_hash_new(MA_HASH_SHA256, ctx))) + if (!(ctx= ma_hash_new(MA_HASH_SHA256))) return 1; ma_hash_input(ctx, digest2, MA_SHA256_HASH_SIZE); ma_hash_input(ctx, salt, salt_len); @@ -460,10 +449,6 @@ int unused3 __attribute__((unused)), va_list unused4 __attribute__((unused))) { -#if defined(HAVE_WINCRYPT) - BCryptOpenAlgorithmProvider(&Sha256Prov, BCRYPT_SHA256_ALGORITHM, NULL, 0); - BCryptOpenAlgorithmProvider(&RsaProv, BCRYPT_RSA_ALGORITHM, NULL, 0); -#endif return 0; } /* }}} */ @@ -471,10 +456,6 @@ /* {{{ auth_caching_sha2_deinit */ static int auth_caching_sha2_deinit(void) { -#if defined(HAVE_WINCRYPT) - BCryptCloseAlgorithmProvider(Sha256Prov, 0); - BCryptCloseAlgorithmProvider(RsaProv, 0); -#endif return 0; } /* }}} */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mariadb-connector-c-3.3.7-src/plugins/auth/ed25519.c new/mariadb-connector-c-3.3.8-src/plugins/auth/ed25519.c --- old/mariadb-connector-c-3.3.7-src/plugins/auth/ed25519.c 2023-09-07 09:36:18.000000000 +0200 +++ new/mariadb-connector-c-3.3.8-src/plugins/auth/ed25519.c 2023-11-01 11:28:04.000000000 +0100 @@ -45,7 +45,6 @@ #include <windows.h> #include <wincrypt.h> #include <bcrypt.h> -extern BCRYPT_ALG_HANDLE Sha512Prov; #elif defined(HAVE_OPENSSL) #include <openssl/rsa.h> #include <openssl/pem.h> @@ -123,9 +122,6 @@ int unused3 __attribute__((unused)), va_list unused4 __attribute__((unused))) { -#if defined(HAVE_WINCRYPT) - BCryptOpenAlgorithmProvider(&Sha512Prov, BCRYPT_SHA512_ALGORITHM, NULL, 0); -#endif return 0; } /* }}} */ @@ -133,9 +129,6 @@ /* {{{ auth_ed25519_deinit */ static int auth_ed25519_deinit(void) { -#if defined(HAVE_WINCRYPT) - BCryptCloseAlgorithmProvider(Sha512Prov, 0); -#endif return 0; } /* }}} */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mariadb-connector-c-3.3.7-src/plugins/auth/my_auth.c new/mariadb-connector-c-3.3.8-src/plugins/auth/my_auth.c --- old/mariadb-connector-c-3.3.7-src/plugins/auth/my_auth.c 2023-09-07 09:36:18.000000000 +0200 +++ new/mariadb-connector-c-3.3.8-src/plugins/auth/my_auth.c 2023-11-01 11:28:04.000000000 +0100 @@ -12,7 +12,7 @@ extern void read_user_name(char *name); extern char *ma_send_connect_attr(MYSQL *mysql, unsigned char *buffer); extern int ma_read_ok_packet(MYSQL *mysql, uchar *pos, ulong length); -extern unsigned char *mysql_net_store_length(unsigned char *packet, size_t length); +extern unsigned char *mysql_net_store_length(unsigned char *packet, ulonglong length); typedef struct { int (*read_packet)(struct st_plugin_vio *vio, uchar **buf); @@ -120,7 +120,7 @@ unsigned int i, last_errno= ((MCPVIO_EXT *)vio)->mysql->net.last_errno; if (last_errno) { - strncpy(last_error, ((MCPVIO_EXT *)vio)->mysql->net.last_error, + memcpy(last_error, ((MCPVIO_EXT *)vio)->mysql->net.last_error, sizeof(last_error) - 1); last_error[sizeof(last_error) - 1]= 0; } @@ -137,7 +137,7 @@ if (last_errno) { MYSQL *mysql= ((MCPVIO_EXT *)vio)->mysql; - strncpy(mysql->net.last_error, last_error, + memcpy(mysql->net.last_error, last_error, sizeof(mysql->net.last_error) - 1); mysql->net.last_error[sizeof(mysql->net.last_error) - 1]= 0; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mariadb-connector-c-3.3.7-src/plugins/pvio/pvio_socket.c new/mariadb-connector-c-3.3.8-src/plugins/pvio/pvio_socket.c --- old/mariadb-connector-c-3.3.7-src/plugins/pvio/pvio_socket.c 2023-09-07 09:36:18.000000000 +0200 +++ new/mariadb-connector-c-3.3.8-src/plugins/pvio/pvio_socket.c 2023-11-01 11:28:04.000000000 +0100 @@ -183,7 +183,7 @@ my_bool pvio_socket_change_timeout(MARIADB_PVIO *pvio, enum enum_pvio_timeout type, int timeout) { - struct timeval tm; + struct timeval tm= {0}; int rc= 0; struct st_pvio_socket *csock= NULL; if (!pvio) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mariadb-connector-c-3.3.7-src/unittest/libmariadb/ps_bugs.c new/mariadb-connector-c-3.3.8-src/unittest/libmariadb/ps_bugs.c --- old/mariadb-connector-c-3.3.7-src/unittest/libmariadb/ps_bugs.c 2023-09-07 09:36:18.000000000 +0200 +++ new/mariadb-connector-c-3.3.8-src/unittest/libmariadb/ps_bugs.c 2023-11-01 11:28:04.000000000 +0100 @@ -3272,7 +3272,7 @@ strcpy(buffer, "create table t_mem_overun("); for (i= 0; i < 1000; i++) { - sprintf(field, "c%d int, ", i); + snprintf(field, sizeof(field), "c%d int, ", i); strcat(buffer, field); } length= (int)strlen(buffer); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mariadb-connector-c-3.3.7-src/win/packaging/CMakeLists.txt new/mariadb-connector-c-3.3.8-src/win/packaging/CMakeLists.txt --- old/mariadb-connector-c-3.3.7-src/win/packaging/CMakeLists.txt 2023-09-07 09:36:18.000000000 +0200 +++ new/mariadb-connector-c-3.3.8-src/win/packaging/CMakeLists.txt 2023-11-01 11:28:04.000000000 +0100 @@ -56,6 +56,8 @@ STRING(REPLACE "mariadb/" "" src_id ${src_id}) IF(${src} MATCHES "mysql/") SET(MARIADB_INCLUDEMYSQL_FILES "${MARIADB_INCLUDEMYSQL_FILES} <File Id=\"${src_id}\" Name=\"${src_name}\" DiskId=\"1\" Source=\"${SRC_DIR}/include/${src}\"/>\n") + ELSEIF (${src} MATCHES "mariadb/") + SET(MARIADB_INCLUDEMARIADB_FILES "${MARIADB_INCLUDEMARIADB_FILES} <File Id=\"${src_id}\" Name=\"${src_name}\" DiskId=\"1\" Source=\"${SRC_DIR}/include/${src}\"/>\n") ELSE() SET(MARIADB_INCLUDE_FILES "${MARIADB_INCLUDE_FILES} <File Id=\"${src_id}\" Name=\"${src_name}\" DiskId=\"1\" Source=\"${SRC_DIR}/include/${src}\"/>\n") ENDIF() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mariadb-connector-c-3.3.7-src/win/packaging/mariadb-connector-c.xml.in new/mariadb-connector-c-3.3.8-src/win/packaging/mariadb-connector-c.xml.in --- old/mariadb-connector-c-3.3.7-src/win/packaging/mariadb-connector-c.xml.in 2023-09-07 09:36:18.000000000 +0200 +++ new/mariadb-connector-c-3.3.8-src/win/packaging/mariadb-connector-c.xml.in 2023-11-01 11:28:04.000000000 +0100 @@ -22,6 +22,7 @@ <Feature Id="IncludeFeature" Title="Include Files" Level="1"> <ComponentRef Id="Includes"/> <ComponentRef Id="MysqlIncludes"/> + <ComponentRef Id="MariadbIncludes"/> </Feature> </Product> @@ -37,6 +38,7 @@ </Directory> <Directory Id="instinclude" Name="include" > <Directory Id="instincludemysql" Name="mysql"/> + <Directory Id="instincludemariadb" Name="mariadb"/> </Directory> </Directory> </Directory> @@ -74,6 +76,10 @@ <CreateFolder/> @MARIADB_INCLUDEMYSQL_FILES@ </Component> + <Component Id="MariadbIncludes" Guid="DEFD4D6B-0143-442A-BEB8-C041F7156BF1" Directory="instincludemariadb" DiskId="1" Win64="@IS_WIN64@"> + <CreateFolder/> + @MARIADB_INCLUDEMARIADB_FILES@ + </Component> </Fragment> </Wix>