Skip to content

Commit

Permalink
Fix of possible crash in config dialog in connection test function
Browse files Browse the repository at this point in the history
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
  • Loading branch information
lawrinn committed Nov 24, 2022
1 parent bf86c4c commit 376a9b0
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 21 deletions.
8 changes: 7 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
12 changes: 9 additions & 3 deletions .travis/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 .
Expand Down Expand Up @@ -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"
Expand Down
6 changes: 5 additions & 1 deletion dsn/odbc_dsn.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion libmariadb
2 changes: 1 addition & 1 deletion ma_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ char* ltrim(char *Str)
{
if (Str)
{
while (*Str && isspace(Str[0]))
while (*Str && iswspace(Str[0]))
++Str;
}
return Str;
Expand Down
7 changes: 4 additions & 3 deletions test/basic.c
Original file line number Diff line number Diff line change
Expand Up @@ -734,15 +734,16 @@ 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));

CHECK_DBC_RC(hdbc1, SQLDriverConnect(hdbc1, NULL, conna, SQL_NTS, NULL,
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));
Expand All @@ -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));

Expand Down
23 changes: 13 additions & 10 deletions test/tap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {\
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion wininstall/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 376a9b0

Please sign in to comment.