1
0
mirror of https://github.com/mariadb-corporation/mariadb-connector-c.git synced 2025-08-07 02:42:49 +03:00

Fix for CONC-384:

fixed length calculation for connection attributes. We now call mysql_net_store_length passing the size of the connection attribute and substract the offset of the passed buffer to determine the correct size.
This commit is contained in:
Georg Richter
2019-02-07 04:14:55 +01:00
parent 1e5e21cae9
commit 70f2964dc4
2 changed files with 29 additions and 7 deletions

View File

@@ -1325,7 +1325,29 @@ static int test_wl6797(MYSQL *mysql)
return OK;
}
static int test_conc384(MYSQL *my __attribute__((unused)))
{
char value[1000];
int len;
MYSQL *mysql= mysql_init(NULL);
memset(&value, 'A', 999);
value[999]= 0;
mysql_optionsv(mysql, MYSQL_OPT_CONNECT_ATTR_ADD, "foo", value);
len= (int)mysql->options.extension->connect_attrs_len;
/* Length: 1 (=len) + 3 (="foo") + 3 (=len) + 999 (="AAA...") = 1006 */
FAIL_IF(len != 1006, "Wrong length");
mysql_optionsv(mysql, MYSQL_OPT_CONNECT_ATTR_DELETE, "foo");
len= (int)mysql->options.extension->connect_attrs_len;
/* Length should be zero after deleting the connection attribute */
FAIL_IF(len != 0, "Wrong length");
mysql_close(mysql);
return OK;
}
struct my_tests_st my_tests[] = {
{"test_conc384", test_conc384, TEST_CONNECTION_NONE, 0, NULL, NULL},
#ifndef _WIN32
{"test_mdev12965", test_mdev12965, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
#endif