Commit f8b4732a authored by monty@mysql.com's avatar monty@mysql.com

Safety fixes (strnmov -> strmake)

parent 1877521f
...@@ -5619,7 +5619,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), ...@@ -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); fprintf(stderr, "Invalid ft-boolean-syntax string: %s\n", argument);
exit(1); exit(1);
} }
strnmov(opt_ft_boolean_syntax, argument, sizeof(ft_boolean_syntax)); strmake(opt_ft_boolean_syntax, argument, sizeof(ft_boolean_syntax)-1);
break; break;
case OPT_SKIP_SAFEMALLOC: case OPT_SKIP_SAFEMALLOC:
#ifdef SAFEMALLOC #ifdef SAFEMALLOC
...@@ -5668,7 +5668,8 @@ static void get_options(int argc,char **argv) ...@@ -5668,7 +5668,8 @@ static void get_options(int argc,char **argv)
int ho_error; int ho_error;
my_getopt_register_get_addr(mysql_getopt_value); 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))) if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option)))
exit(ho_error); exit(ho_error);
if (argc > 0) if (argc > 0)
...@@ -5724,7 +5725,8 @@ static void get_options(int argc,char **argv) ...@@ -5724,7 +5725,8 @@ static void get_options(int argc,char **argv)
table_alias_charset= (lower_case_table_names ? table_alias_charset= (lower_case_table_names ?
files_charset_info : files_charset_info :
&my_charset_bin); &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) if (opt_short_log_format)
opt_specialflag|= SPECIAL_SHORT_LOG_FORMAT; opt_specialflag|= SPECIAL_SHORT_LOG_FORMAT;
......
...@@ -860,7 +860,7 @@ static void sys_default_init_slave(THD* thd, enum_var_type type) ...@@ -860,7 +860,7 @@ static void sys_default_init_slave(THD* thd, enum_var_type type)
static int sys_check_ftb_syntax(THD *thd, set_var *var) static int sys_check_ftb_syntax(THD *thd, set_var *var)
{ {
if (thd->master_access & SUPER_ACL) if (thd->master_access & SUPER_ACL)
return ft_boolean_check_syntax_string(var->value->str_value.ptr()) ? return ft_boolean_check_syntax_string(var->value->str_value.c_ptr()) ?
-1 : 0; -1 : 0;
else else
{ {
...@@ -871,13 +871,15 @@ static int sys_check_ftb_syntax(THD *thd, set_var *var) ...@@ -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) 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; return 0;
} }
static void sys_default_ftb_syntax(THD *thd, enum_var_type type) 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) ...@@ -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) if ((file=my_create(path, CREATE_MODE,O_RDWR | O_TRUNC,MYF(MY_WME))) >= 0)
{ {
ulong length; ulong length;
CHARSET_INFO *cs= (create && create->default_table_charset) ? CHARSET_INFO *cs= ((create && create->default_table_charset) ?
create->default_table_charset : create->default_table_charset :
thd->variables.collation_server; thd->variables.collation_server);
length= my_sprintf(buf,(buf, length= my_sprintf(buf,(buf,
"default-character-set=%s\ndefault-collation=%s\n", "default-character-set=%s\ndefault-collation=%s\n",
cs->csname,cs->name)); cs->csname,cs->name));
...@@ -116,7 +116,8 @@ bool load_db_opt(THD *thd, const char *path, HA_CREATE_INFO *create) ...@@ -116,7 +116,8 @@ bool load_db_opt(THD *thd, const char *path, HA_CREATE_INFO *create)
{ {
if (!strncmp(buf,"default-character-set", (pos-buf))) if (!strncmp(buf,"default-character-set", (pos-buf)))
{ {
if (!(create->default_table_charset= get_charset_by_csname(pos+1, if (!(create->default_table_charset=
get_charset_by_csname(pos+1,
MY_CS_PRIMARY, MY_CS_PRIMARY,
MYF(0)))) MYF(0))))
{ {
......
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