From 376a9b07aa93c065d86234519ea17305736dfb32 Mon Sep 17 00:00:00 2001 From: Lawrin Novitsky Date: Wed, 23 Nov 2022 20:40:15 +0100 Subject: [PATCH] Fix of possible crash in config dialog in connection test function Updated libmariadb to v3.3.3 tag. Removed dependency of msi file on gssapi client plugin, as it is static my default. Some changes in tests and travis config --- .travis.yml | 8 +++++++- .travis/script.sh | 12 +++++++++--- dsn/odbc_dsn.c | 6 +++++- libmariadb | 2 +- ma_common.c | 2 +- test/basic.c | 7 ++++--- test/tap.h | 23 +++++++++++++---------- wininstall/CMakeLists.txt | 2 +- 8 files changed, 41 insertions(+), 21 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2d9598a8..a90963e8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -48,12 +48,15 @@ jobs: - env: srv=xpand - env: srv=mysql v=5.7 - env: srv=mysql v=8.0 - - env: srv=mariadb v=10.8 + - env: srv=mariadb v=10.6 os: windows - os: osx - os: linux arch: s390x dist: focal + - env: srv=maxscale MAXSCALE_TEST_DISABLE=true + - env: srv=skysql SKYSQL=true + - env: srv=skysql-ha SKYSQL_HA=true MAXSCALE_TEST_DISABLE=true include: - stage: Minimal env: srv=mariadb v=10.6 local=1 @@ -104,6 +107,9 @@ jobs: name: "CS build" - os: osx compiler: clang + before_script: + - brew install openssl + - brew install libiodbc - os: linux arch: s390x dist: focal diff --git a/.travis/script.sh b/.travis/script.sh index f3ae766a..02a094c1 100755 --- a/.travis/script.sh +++ b/.travis/script.sh @@ -26,23 +26,28 @@ else if [ -n "$MYSQL_TEST_SSL_PORT" ] ; then export TEST_SSL_PORT=$MYSQL_TEST_SSL_PORT fi + if ! [ "$TRAVIS_OS_NAME" = "osx" ] ; then + sudo apt install cmake + fi fi export TEST_DSN=maodbc_test export TEST_DRIVER=maodbc_test export TEST_UID=$TEST_DB_USER export TEST_SERVER=$TEST_DB_HOST +set +x export TEST_PASSWORD=$TEST_DB_PASSWORD +# Just to see in log that this was done +echo "export TEST_PASSWORD=******************" +set -ex export TEST_PORT=$TEST_DB_PORT export TEST_SCHEMA=testo -export TEST_VERBOSE=true export TEST_SOCKET= if [ "${TEST_REQUIRE_TLS}" = "1" ] ; then export TEST_USETLS=true export TEST_ADD_PARAM="FORCETLS=1" fi -sudo apt install cmake if [ "$TRAVIS_OS_NAME" = "windows" ] ; then cmake -DCONC_WITH_MSI=OFF -DCONC_WITH_UNIT_TESTS=OFF -DWITH_MSI=OFF -DCMAKE_BUILD_TYPE=RelWithDebInfo -DWITH_SSL=SCHANNEL . @@ -104,7 +109,8 @@ cd ./test export ODBCINI="$PWD/odbc.ini" export ODBCSYSINI=$PWD -cat $ODBCINI +cat $ODBCSYSINI/odbcinst.ini +cat $ODBCSYSINI/odbc.ini | grep -v TEST_PASSWORD ctest --output-on-failure # Running tests 2nd time with resultset streaming. "${TEST_REQUIRE_TLS}" = "1" basically means "not on skysql" diff --git a/dsn/odbc_dsn.c b/dsn/odbc_dsn.c index b3a9638d..c9a9c12e 100644 --- a/dsn/odbc_dsn.c +++ b/dsn/odbc_dsn.c @@ -559,7 +559,11 @@ char* HidePwd(char *ConnStr) } ++Ptr; } - ++Ptr; + /* Do not move if we already at the terminating null */ + if (*Ptr) + { + ++Ptr; + } } return ConnStr; diff --git a/libmariadb b/libmariadb index 1bd8c8bf..d9af4fcb 160000 --- a/libmariadb +++ b/libmariadb @@ -1 +1 @@ -Subproject commit 1bd8c8bf39c259a1b1713974684e24d168a09d13 +Subproject commit d9af4fcbc6a7c0ab72b38bb47e0d4fa1f1f83316 diff --git a/ma_common.c b/ma_common.c index fd4f8ea7..7d115d4f 100644 --- a/ma_common.c +++ b/ma_common.c @@ -44,7 +44,7 @@ char* ltrim(char *Str) { if (Str) { - while (*Str && isspace(Str[0])) + while (*Str && iswspace(Str[0])) ++Str; } return Str; diff --git a/test/basic.c b/test/basic.c index ee1952f9..4a53806c 100644 --- a/test/basic.c +++ b/test/basic.c @@ -734,7 +734,8 @@ ODBC_TEST(t_driverconnect_outstring) 0, &conn_out_len, SQL_DRIVER_COMPLETE)); is_num(conn_out_len, strlen((const char*)conna)); - IS_STR(conna_out, conna, conn_out_len); + /* Not to show sensitive data in automatic testing logs */ + IS_STR_EX(conna_out, conna, conn_out_len, FALSE); CHECK_DBC_RC(hdbc1, SQLDisconnect(hdbc1)); @@ -742,7 +743,7 @@ ODBC_TEST(t_driverconnect_outstring) 0, &conn_out_len, SQL_DRIVER_COMPLETE_REQUIRED)); is_num(conn_out_len, strlen((const char*)conna)); - IS_STR(conna_out, conna, conn_out_len); + IS_STR_EX(conna_out, conna, conn_out_len, FALSE); CHECK_DBC_RC(hdbc1, SQLDisconnect(hdbc1)); CHECK_DBC_RC(hdbc1, SQLFreeHandle(SQL_HANDLE_DBC, hdbc1)); @@ -755,7 +756,7 @@ ODBC_TEST(t_driverconnect_outstring) SQL_DRIVER_NOPROMPT)); /* Old iODBC returns octets count here */ is_num(conn_out_len, strlen((const char*)conna)*lenCorrector); - IS_WSTR(connw_out, connw, strlen((const char*)conna)); + IS_WSTR_EX(connw_out, connw, strlen((const char*)conna), FALSE); CHECK_DBC_RC(hdbc1, SQLDisconnect(hdbc1)); diff --git a/test/tap.h b/test/tap.h index 0190333a..2c0c4ba7 100644 --- a/test/tap.h +++ b/test/tap.h @@ -651,9 +651,10 @@ do {\ } #define IS(A) if (!(A)) { diag("Error in %s:%d", __FILE__, __LINE__); return FAIL; } -#define IS_STR(A,B,C) do {const char *loc_a=(const char *)(A), *loc_b=(const char *)(B);\ -diag("%s %s", loc_a, loc_b);\ +#define IS_STR_EX(A,B,C,D) do {const char *loc_a=(const char *)(A), *loc_b=(const char *)(B);\ +if ((D)) diag("%s %s", loc_a, loc_b);\ FAIL_IF(loc_a == NULL || loc_b == NULL || strncmp(loc_a, loc_b, (C)) != 0, "Strings do not match"); } while(0) +#define IS_STR(A,B,C) IS_STR_EX(A,B,C,TRUE) #define is_num(A,B) \ do {\ @@ -1235,21 +1236,23 @@ void printHex(char *str, int len) } } -#define IS_WSTR(a, b, c) \ +#define IS_WSTR_EX(a, b, c, _OUTPUT) \ do { \ SQLWCHAR *val_a= (SQLWCHAR*)(a), *val_b= (SQLWCHAR*)(b); \ int val_len= (int)(c); \ if (memcmp(val_a, val_b, val_len * sizeof(SQLWCHAR)) != 0) { \ - printf("#%s('", #a); \ - printHex((char*)val_a, val_len*sizeof(SQLWCHAR)); \ - printf("') != %s('", #b); \ - printHex((char*)val_b, val_len*sizeof(SQLWCHAR)); \ - printf("') in %s on line %d", __FILE__, __LINE__); \ - printf("\n"); \ + if ((_OUTPUT)) {\ + printf("#%s('", #a); \ + printHex((char*)val_a, val_len*sizeof(SQLWCHAR)); \ + printf("') != %s('", #b); \ + printHex((char*)val_b, val_len*sizeof(SQLWCHAR)); \ + printf("') in %s on line %d", __FILE__, __LINE__); \ + printf("\n");\ + }\ return FAIL;\ } \ } while (0); - +#define IS_WSTR(a, b, c) IS_WSTR_EX(a, b, c, TRUE) SQLWCHAR *dup_char_as_sqlwchar(SQLCHAR *from) diff --git a/wininstall/CMakeLists.txt b/wininstall/CMakeLists.txt index 8e167b52..c0751ff7 100644 --- a/wininstall/CMakeLists.txt +++ b/wininstall/CMakeLists.txt @@ -126,7 +126,7 @@ IF(NOT USE_SYSTEM_INSTALLED_LIB) IF(ALL_PLUGINS_STATIC) ADD_DEPENDENCIES(ODBC_WIX maodbc maodbcs) ELSE() - ADD_DEPENDENCIES(ODBC_WIX maodbc maodbcs dialog caching_sha2_password auth_gssapi_client sha256_password mysql_clear_password) + ADD_DEPENDENCIES(ODBC_WIX maodbc maodbcs dialog caching_sha2_password sha256_password mysql_clear_password) ENDIF() ENDIF()