From a1469b407a2494baeed3aa155a1e1f525003d110 Mon Sep 17 00:00:00 2001 From: Georg Richter Date: Mon, 11 Feb 2019 20:13:17 +0100 Subject: [PATCH 1/7] Fix test for expired password. Followup of 02bf9033ef0f52fd4c6c6e512389729f5c4545fd --- unittest/libmariadb/connection.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/unittest/libmariadb/connection.c b/unittest/libmariadb/connection.c index e06088b6..60546692 100644 --- a/unittest/libmariadb/connection.c +++ b/unittest/libmariadb/connection.c @@ -1345,6 +1345,10 @@ static int test_expired_pw(MYSQL *my) my_test_connect(mysql, hostname, "foo", "foo", schema, port, socketname, 0); + /* we should be in sandbox mode now, only set commands should be allowed */ + rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1"); + FAIL_IF(!rc, "Error expected (we are in sandbox mode"); + diag("error: %d %s", mysql_errno(mysql), mysql_error(mysql)); FAIL_IF(mysql_errno(mysql) != ER_MUST_CHANGE_PASSWORD && mysql_errno(mysql) != ER_MUST_CHANGE_PASSWORD_LOGIN, "Error 1820/1862 expected"); From b6fa103f371ac02830b723c8972eb99554b0d2c7 Mon Sep 17 00:00:00 2001 From: Georg Richter Date: Tue, 12 Feb 2019 19:30:57 +0100 Subject: [PATCH 2/7] bump version number to 3.0.10 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 853089ea..937c29d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,7 +36,7 @@ SET(CC_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) SET(CPACK_PACKAGE_VERSION_MAJOR 3) SET(CPACK_PACKAGE_VERSION_MINOR 0) -SET(CPACK_PACKAGE_VERSION_PATCH 9) +SET(CPACK_PACKAGE_VERSION_PATCH 10) 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 + From 0acf529e3403e320716f7a88a7a775f91fe0b055 Mon Sep 17 00:00:00 2001 From: Georg Richter Date: Tue, 19 Feb 2019 08:44:19 +0100 Subject: [PATCH 3/7] Fix for MDEV-18634: Even if this test is intended to fail we need to pass valid memory buffer to simulate overflow (length > length of sql statement). --- unittest/libmariadb/errors.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/unittest/libmariadb/errors.c b/unittest/libmariadb/errors.c index 9c94a377..b44b55ff 100644 --- a/unittest/libmariadb/errors.c +++ b/unittest/libmariadb/errors.c @@ -239,6 +239,7 @@ static int test_parse_error_and_bad_length(MYSQL *mysql) { MYSQL_STMT *stmt; int rc; + char stmt_str[128]; /* check that we get 4 syntax errors over the 4 calls */ @@ -254,7 +255,9 @@ static int test_parse_error_and_bad_length(MYSQL *mysql) mysql_stmt_close(stmt); stmt= mysql_stmt_init(mysql); FAIL_UNLESS(stmt, ""); - rc= mysql_stmt_prepare(stmt, "SHOW DATABASES", 100); + memset(stmt_str, 0, 100); + strcpy(stmt_str, "SHOW DATABASES"); + rc= mysql_stmt_prepare(stmt, stmt_str, 99); FAIL_IF(!rc, "Error expected"); mysql_stmt_close(stmt); return OK; From 31ae1278aa4ba2e4832c279d71f3a06ef80ffbea Mon Sep 17 00:00:00 2001 From: Georg Richter Date: Sun, 24 Feb 2019 20:00:02 +0100 Subject: [PATCH 4/7] Fix for MDEV-18721 (Host option in configuration file is ignored.) We need to check the passed host variable after the configuration file was read. Thanks to Peter Penchev and Corey Hickey for providing patches. --- libmariadb/mariadb_lib.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libmariadb/mariadb_lib.c b/libmariadb/mariadb_lib.c index 971982a7..ed84b8c4 100644 --- a/libmariadb/mariadb_lib.c +++ b/libmariadb/mariadb_lib.c @@ -1215,11 +1215,6 @@ MYSQL *mthd_my_real_connect(MYSQL *mysql, const char *host, const char *user, if (!mysql->methods) mysql->methods= &MARIADB_DEFAULT_METHODS; - if (!host || !host[0]) - host = mysql->options.host; - - ma_set_connect_attrs(mysql, host); - if (net->pvio) /* check if we are already connected */ { SET_CLIENT_ERROR(mysql, CR_ALREADY_CONNECTED, SQLSTATE_UNKNOWN, 0); @@ -1238,6 +1233,11 @@ MYSQL *mthd_my_real_connect(MYSQL *mysql, const char *host, const char *user, mysql->options.my_cnf_file=mysql->options.my_cnf_group=0; } + if (!host || !host[0]) + host = mysql->options.host; + + ma_set_connect_attrs(mysql, host); + #ifndef WIN32 if (mysql->options.protocol > MYSQL_PROTOCOL_SOCKET) { From 68d05007bbf0dd9ef725bddf312fbb72ed0c7d52 Mon Sep 17 00:00:00 2001 From: Georg Richter Date: Sat, 2 Mar 2019 07:54:06 +0100 Subject: [PATCH 5/7] Fix for CONC-392: Fixed crash when server sent session tracking information with session type SESSION_TRACK_STATE_CHANGE. In this special case the packet doesn't contain the overall length. (see https://mariadb.com/kb/en/library/ok_packet/). --- libmariadb/mariadb_lib.c | 3 ++- unittest/libmariadb/connection.c | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/libmariadb/mariadb_lib.c b/libmariadb/mariadb_lib.c index ed84b8c4..93e89f1b 100644 --- a/libmariadb/mariadb_lib.c +++ b/libmariadb/mariadb_lib.c @@ -2034,7 +2034,8 @@ int ma_read_ok_packet(MYSQL *mysql, uchar *pos, ulong length) case SESSION_TRACK_STATE_CHANGE: case SESSION_TRACK_TRANSACTION_CHARACTERISTICS: case SESSION_TRACK_SYSTEM_VARIABLES: - net_field_length(&pos); /* ignore total length, item length will follow next */ + if (si_type != SESSION_TRACK_STATE_CHANGE) + net_field_length(&pos); /* ignore total length, item length will follow next */ plen= net_field_length(&pos); if (!ma_multi_malloc(0, &session_item, sizeof(LIST), diff --git a/unittest/libmariadb/connection.c b/unittest/libmariadb/connection.c index 60546692..d32038fd 100644 --- a/unittest/libmariadb/connection.c +++ b/unittest/libmariadb/connection.c @@ -1602,8 +1602,28 @@ static int test_conc312(MYSQL *my) return OK; } +static int test_conc392(MYSQL *mysql) +{ + int rc; + const char *data; + size_t len; + + rc= mysql_query(mysql, "set session_track_state_change=1"); + check_mysql_rc(rc, mysql); + + if (mysql_session_track_get_first(mysql, SESSION_TRACK_STATE_CHANGE, &data, &len)) + { + diag("session_track_get_first failed"); + return FAIL; + } + + FAIL_IF(len != 1, "Expected length 1"); + return OK; +} + struct my_tests_st my_tests[] = { + {"test_conc392", test_conc392, TEST_CONNECTION_DEFAULT, 0, NULL, NULL}, {"test_conc312", test_conc312, TEST_CONNECTION_DEFAULT, 0, NULL, NULL}, {"test_conc351", test_conc351, TEST_CONNECTION_NONE, 0, NULL, NULL}, {"test_conc332", test_conc332, TEST_CONNECTION_NONE, 0, NULL, NULL}, From 0cc2df4180914473f4494a7244f3bf31747c8efe Mon Sep 17 00:00:00 2001 From: Georg Richter Date: Sat, 2 Mar 2019 14:26:55 +0100 Subject: [PATCH 6/7] Follow up of 68d05007bbf0dd9ef725bddf312fbb72ed0c7d52: Skip test if the server doesn't support session tracking --- unittest/libmariadb/connection.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/unittest/libmariadb/connection.c b/unittest/libmariadb/connection.c index d32038fd..e8ca84ff 100644 --- a/unittest/libmariadb/connection.c +++ b/unittest/libmariadb/connection.c @@ -1607,6 +1607,15 @@ static int test_conc392(MYSQL *mysql) int rc; const char *data; size_t len; + ulong capabilities= 0; + + mariadb_get_infov(mysql, MARIADB_CONNECTION_SERVER_CAPABILITIES, &capabilities); + if (!(capabilities & CLIENT_SESSION_TRACKING)) + { + mysql_close(mysql); + diag("Server doesn't support session tracking (cap=%lu)", mysql->server_capabilities); + return SKIP; + } rc= mysql_query(mysql, "set session_track_state_change=1"); check_mysql_rc(rc, mysql); From f24915057c473b324e1c60cdc78eda902df910fe Mon Sep 17 00:00:00 2001 From: Georg Richter Date: Sat, 2 Mar 2019 14:49:27 +0100 Subject: [PATCH 7/7] Don't close default connection in test_conc392 in case we have to skip test --- unittest/libmariadb/connection.c | 1 - 1 file changed, 1 deletion(-) diff --git a/unittest/libmariadb/connection.c b/unittest/libmariadb/connection.c index e8ca84ff..a7b67baf 100644 --- a/unittest/libmariadb/connection.c +++ b/unittest/libmariadb/connection.c @@ -1612,7 +1612,6 @@ static int test_conc392(MYSQL *mysql) mariadb_get_infov(mysql, MARIADB_CONNECTION_SERVER_CAPABILITIES, &capabilities); if (!(capabilities & CLIENT_SESSION_TRACKING)) { - mysql_close(mysql); diag("Server doesn't support session tracking (cap=%lu)", mysql->server_capabilities); return SKIP; }