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

followup for e2df6d2: default directories, files, and groups

* do not read ini_exts array beyond the end
* do not use local variable (val) address outside of the variable's scope
* do not read $HOME/my.cnf
* do not create files in the user's $HOME, use $MYSQL_TMP_DIR
* test reading of the executable name group
* fail the test if .my.cnf cannot be opened
This commit is contained in:
Sergei Golubchik
2017-07-04 11:42:05 +02:00
parent ea8a31e63a
commit 67277fb1d1
3 changed files with 41 additions and 48 deletions

View File

@@ -701,35 +701,35 @@ my_bool _mariadb_set_conf_option(MYSQL *mysql, const char *config_option, const
{
if (!strcmp(mariadb_defaults[i].conf_key, config_option))
{
my_bool val_bool;
int val_int;
size_t val_sizet;
int rc;
void *option_val= NULL;
switch (mariadb_defaults[i].type) {
case MARIADB_OPTION_BOOL:
{
my_bool val= 0;
if (config_value)
val= atoi(config_value);
option_val= &val;
break;
}
val_bool= 0;
if (config_value)
val_bool= atoi(config_value);
option_val= &val_bool;
break;
case MARIADB_OPTION_INT:
{
int val= 0;
if (config_value)
val= atoi(config_value);
option_val= &val;
break;
}
val_int= 0;
if (config_value)
val_int= atoi(config_value);
option_val= &val_int;
break;
case MARIADB_OPTION_SIZET:
{
size_t val= 0;
if (config_value)
val= strtol(config_value, NULL, 10);
option_val= &val;
break;
}
default:
option_val= (void *)config_value;
val_sizet= 0;
if (config_value)
val_sizet= strtol(config_value, NULL, 10);
option_val= &val_sizet;
break;
case MARIADB_OPTION_STR:
option_val= (void*)config_value;
break;
case MARIADB_OPTION_NONE:
break;
}
rc= mysql_optionsv(mysql, mariadb_defaults[i].option, option_val);
return(test(rc));