diff options
author | Sergei Golubchik <sergii@pisem.net> | 2013-04-17 19:42:34 +0200 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2013-04-17 19:42:34 +0200 |
commit | 07315d36030bd1cbe6acfeb3e8f60c49ba876a10 (patch) | |
tree | 9c74de4bb97507ece945576df7073a7a28f07674 /client | |
parent | 4656060f118caba30912cca2557d72fcea307283 (diff) | |
download | mariadb-git-07315d36030bd1cbe6acfeb3e8f60c49ba876a10.tar.gz |
strmake_buf(X,Y) helper, equivalent to strmake(X,Y,sizeof(X)-1)
with a bit of lame protection against abuse.
Diffstat (limited to 'client')
-rw-r--r-- | client/mysql.cc | 22 | ||||
-rw-r--r-- | client/mysqltest.cc | 3 |
2 files changed, 12 insertions, 13 deletions
diff --git a/client/mysql.cc b/client/mysql.cc index ad792abc23f..3cd078ac1ce 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -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) { diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 8c6c1cb3408..2dde607a016 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -6335,8 +6335,7 @@ void do_delimiter(struct st_command* command) if (!(*p)) die("Can't set empty delimiter"); - strmake(delimiter, p, sizeof(delimiter) - 1); - delimiter_length= strlen(delimiter); + delimiter_length= strmake_buf(delimiter, p) - delimiter; DBUG_PRINT("exit", ("delimiter: %s", delimiter)); command->last_argument= p + delimiter_length; |