1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

strmake_buf(X,Y) helper, equivalent to strmake(X,Y,sizeof(X)-1)

with a bit of lame protection against abuse.
This commit is contained in:
Sergei Golubchik
2013-04-17 19:42:34 +02:00
parent 4656060f11
commit 07315d3603
27 changed files with 102 additions and 121 deletions

View File

@ -1635,7 +1635,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
{
switch(optid) {
case OPT_CHARSETS_DIR:
strmake(mysql_charsets_dir, argument, sizeof(mysql_charsets_dir) - 1);
strmake_buf(mysql_charsets_dir, argument);
charsets_dir = mysql_charsets_dir;
break;
case OPT_DELIMITER:
@ -1648,7 +1648,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
/* Check that delimiter does not contain a backslash */
if (!strstr(argument, "\\"))
{
strmake(delimiter, argument, sizeof(delimiter) - 1);
strmake_buf(delimiter, argument);
}
else
{
@ -1680,7 +1680,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
if (argument && strlen(argument))
{
default_pager_set= 1;
strmake(pager, argument, sizeof(pager) - 1);
strmake_buf(pager, argument);
strmov(default_pager, pager);
}
else if (default_pager_set)
@ -2961,7 +2961,7 @@ com_charset(String *buffer __attribute__((unused)), char *line)
{
char buff[256], *param;
CHARSET_INFO * new_cs;
strmake(buff, line, sizeof(buff) - 1);
strmake_buf(buff, line);
param= get_arg(buff, 0);
if (!param || !*param)
{
@ -3198,7 +3198,7 @@ static void init_tee(const char *file_name)
return;
}
OUTFILE = new_outfile;
strmake(outfile, file_name, FN_REFLEN-1);
strmake_buf(outfile, file_name);
tee_fprintf(stdout, "Logging to file '%s'\n", file_name);
opt_outfile= 1;
return;
@ -3827,7 +3827,7 @@ com_tee(String *buffer __attribute__((unused)),
/* eliminate the spaces before the parameters */
while (my_isspace(charset_info,*param))
param++;
end= strmake(file_name, param, sizeof(file_name) - 1);
end= strmake_buf(file_name, param);
/* remove end space from command line */
while (end > file_name && (my_isspace(charset_info,end[-1]) ||
my_iscntrl(charset_info,end[-1])))
@ -3888,7 +3888,7 @@ com_pager(String *buffer __attribute__((unused)),
}
else
{
end= strmake(pager_name, param, sizeof(pager_name)-1);
end= strmake_buf(pager_name, param);
while (end > pager_name && (my_isspace(charset_info,end[-1]) ||
my_iscntrl(charset_info,end[-1])))
end--;
@ -4101,7 +4101,7 @@ static int com_source(String *buffer __attribute__((unused)),
INFO_ERROR, 0);
while (my_isspace(charset_info,*param))
param++;
end=strmake(source_name,param,sizeof(source_name)-1);
end=strmake_buf(source_name, param);
while (end > source_name && (my_isspace(charset_info,end[-1]) ||
my_iscntrl(charset_info,end[-1])))
end--;
@ -4154,7 +4154,7 @@ com_delimiter(String *buffer __attribute__((unused)), char *line)
{
char buff[256], *tmp;
strmake(buff, line, sizeof(buff) - 1);
strmake_buf(buff, line);
tmp= get_arg(buff, 0);
if (!tmp || !*tmp)
@ -4171,7 +4171,7 @@ com_delimiter(String *buffer __attribute__((unused)), char *line)
return 0;
}
}
strmake(delimiter, tmp, sizeof(delimiter) - 1);
strmake_buf(delimiter, tmp);
delimiter_length= (int)strlen(delimiter);
delimiter_str= delimiter;
return 0;
@ -4185,7 +4185,7 @@ com_use(String *buffer __attribute__((unused)), char *line)
int select_db;
bzero(buff, sizeof(buff));
strmake(buff, line, sizeof(buff) - 1);
strmake_buf(buff, line);
tmp= get_arg(buff, 0);
if (!tmp || !*tmp)
{