You've already forked mariadb-connector-c
mirror of
https://github.com/mariadb-corporation/mariadb-connector-c.git
synced 2025-08-08 14:02:17 +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:
@@ -2627,13 +2627,13 @@ mysql_get_client_info(void)
|
|||||||
|
|
||||||
static size_t get_store_length(size_t length)
|
static size_t get_store_length(size_t length)
|
||||||
{
|
{
|
||||||
if (length < (size_t) L64(251))
|
#define MAX_STORE_SIZE 9
|
||||||
return 1;
|
unsigned char buffer[MAX_STORE_SIZE], *p;
|
||||||
if (length < (size_t) L64(65536))
|
|
||||||
return 2;
|
/* We just store the length and substract offset of our buffer
|
||||||
if (length < (size_t) L64(16777216))
|
to determine the length */
|
||||||
return 3;
|
p= mysql_net_store_length(buffer, length);
|
||||||
return 9;
|
return p - buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
uchar *ma_get_hash_keyval(const uchar *hash_entry,
|
uchar *ma_get_hash_keyval(const uchar *hash_entry,
|
||||||
|
@@ -1325,7 +1325,29 @@ static int test_wl6797(MYSQL *mysql)
|
|||||||
return OK;
|
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[] = {
|
struct my_tests_st my_tests[] = {
|
||||||
|
{"test_conc384", test_conc384, TEST_CONNECTION_NONE, 0, NULL, NULL},
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
{"test_mdev12965", test_mdev12965, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
{"test_mdev12965", test_mdev12965, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user