Commit 51a6b4f4 authored by unknown's avatar unknown

Safety fixes (strnmov -> strmake)



sql/mysqld.cc:
  Safety fix
sql/set_var.cc:
  Safety fix
sql/sql_db.cc:
  indentation cleanup
parent 403255b8
......@@ -5619,7 +5619,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
fprintf(stderr, "Invalid ft-boolean-syntax string: %s\n", argument);
exit(1);
}
strnmov(opt_ft_boolean_syntax, argument, sizeof(ft_boolean_syntax));
strmake(opt_ft_boolean_syntax, argument, sizeof(ft_boolean_syntax)-1);
break;
case OPT_SKIP_SAFEMALLOC:
#ifdef SAFEMALLOC
......@@ -5668,7 +5668,8 @@ static void get_options(int argc,char **argv)
int ho_error;
my_getopt_register_get_addr(mysql_getopt_value);
strnmov(opt_ft_boolean_syntax, ft_boolean_syntax, sizeof(ft_boolean_syntax));
strmake(opt_ft_boolean_syntax, ft_boolean_syntax,
sizeof(ft_boolean_syntax)-1);
if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option)))
exit(ho_error);
if (argc > 0)
......@@ -5724,7 +5725,8 @@ static void get_options(int argc,char **argv)
table_alias_charset= (lower_case_table_names ?
files_charset_info :
&my_charset_bin);
strnmov(ft_boolean_syntax, opt_ft_boolean_syntax, sizeof(ft_boolean_syntax));
strmake(ft_boolean_syntax, opt_ft_boolean_syntax,
sizeof(ft_boolean_syntax)-1);
if (opt_short_log_format)
opt_specialflag|= SPECIAL_SHORT_LOG_FORMAT;
......
......@@ -860,8 +860,8 @@ static void sys_default_init_slave(THD* thd, enum_var_type type)
static int sys_check_ftb_syntax(THD *thd, set_var *var)
{
if (thd->master_access & SUPER_ACL)
return ft_boolean_check_syntax_string(var->value->str_value.ptr()) ?
-1 : 0;
return ft_boolean_check_syntax_string(var->value->str_value.c_ptr()) ?
-1 : 0;
else
{
my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), "SUPER");
......@@ -871,13 +871,15 @@ static int sys_check_ftb_syntax(THD *thd, set_var *var)
static bool sys_update_ftb_syntax(THD *thd, set_var * var)
{
strnmov(ft_boolean_syntax, var->value->str_value.ptr(), sizeof(ft_boolean_syntax));
strmake(ft_boolean_syntax, var->value->str_value.c_ptr(),
sizeof(ft_boolean_syntax)-1);
return 0;
}
static void sys_default_ftb_syntax(THD *thd, enum_var_type type)
{
strnmov(ft_boolean_syntax, opt_ft_boolean_syntax, sizeof(ft_boolean_syntax));
strmake(ft_boolean_syntax, opt_ft_boolean_syntax,
sizeof(ft_boolean_syntax)-1);
}
/*
......
......@@ -58,9 +58,9 @@ static bool write_db_opt(THD *thd, const char *path, HA_CREATE_INFO *create)
if ((file=my_create(path, CREATE_MODE,O_RDWR | O_TRUNC,MYF(MY_WME))) >= 0)
{
ulong length;
CHARSET_INFO *cs= (create && create->default_table_charset) ?
create->default_table_charset :
thd->variables.collation_server;
CHARSET_INFO *cs= ((create && create->default_table_charset) ?
create->default_table_charset :
thd->variables.collation_server);
length= my_sprintf(buf,(buf,
"default-character-set=%s\ndefault-collation=%s\n",
cs->csname,cs->name));
......@@ -116,9 +116,10 @@ bool load_db_opt(THD *thd, const char *path, HA_CREATE_INFO *create)
{
if (!strncmp(buf,"default-character-set", (pos-buf)))
{
if (!(create->default_table_charset= get_charset_by_csname(pos+1,
MY_CS_PRIMARY,
MYF(0))))
if (!(create->default_table_charset=
get_charset_by_csname(pos+1,
MY_CS_PRIMARY,
MYF(0))))
{
sql_print_error(ER(ER_UNKNOWN_CHARACTER_SET),pos+1);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment