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 MDEV-12446:
When no default configuration is present, C/C crashed due to double free in ma_default.c
This commit is contained in:
@@ -93,13 +93,12 @@ my_bool _mariadb_read_options(MYSQL *mysql, const char *config_file,
|
|||||||
filename= (char *)malloc(FN_REFLEN + 10);
|
filename= (char *)malloc(FN_REFLEN + 10);
|
||||||
if (!_mariadb_get_default_file(filename, FN_REFLEN + 10))
|
if (!_mariadb_get_default_file(filename, FN_REFLEN + 10))
|
||||||
{
|
{
|
||||||
free(filename);
|
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(file = ma_open(filename, "r", NULL)))
|
if (!(file = ma_open(filename, "r", NULL)))
|
||||||
return 1;
|
goto err;
|
||||||
|
|
||||||
while (ma_gets(buff,sizeof(buff)-1,file))
|
while (ma_gets(buff,sizeof(buff)-1,file))
|
||||||
{
|
{
|
||||||
|
@@ -1069,7 +1069,28 @@ static int test_reset(MYSQL *mysql)
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int test_mdev12446(MYSQL *my __attribute__((unused)))
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
if specified file didn't exist, valgrind reported a leak,
|
||||||
|
if no file was specified and no default file is installed,
|
||||||
|
C/C crashed due to double free.
|
||||||
|
*/
|
||||||
|
MYSQL *mysql= mysql_init(NULL);
|
||||||
|
mysql_options(mysql, MYSQL_READ_DEFAULT_FILE, "file.notfound");
|
||||||
|
FAIL_IF(!my_test_connect(mysql, hostname, username, password, schema,
|
||||||
|
port, socketname, 0), mysql_error(mysql));
|
||||||
|
mysql_close(mysql);
|
||||||
|
mysql= mysql_init(NULL);
|
||||||
|
mysql_options(mysql, MYSQL_READ_DEFAULT_GROUP, "notfound");
|
||||||
|
FAIL_IF(!my_test_connect(mysql, hostname, username, password, schema,
|
||||||
|
port, socketname, 0), mysql_error(mysql));
|
||||||
|
mysql_close(mysql);
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
struct my_tests_st my_tests[] = {
|
struct my_tests_st my_tests[] = {
|
||||||
|
{"test_mdev12446", test_mdev12446, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||||
{"test_reset", test_reset, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
{"test_reset", test_reset, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||||
{"test_unix_socket_close", test_unix_socket_close, TEST_CONNECTION_NONE, 0, NULL, NULL},
|
{"test_unix_socket_close", test_unix_socket_close, TEST_CONNECTION_NONE, 0, NULL, NULL},
|
||||||
{"test_sess_track_db", test_sess_track_db, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
{"test_sess_track_db", test_sess_track_db, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||||
|
Reference in New Issue
Block a user