summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2015-12-09 10:00:49 +0100
committerSergei Golubchik <serg@mariadb.org>2015-12-09 10:00:49 +0100
commitabf9d35213ba482a3927651ddb98baa47aeb34fd (patch)
tree567bee47df18c21d5fbc09bbb4fee4e8f26df4d9 /client
parent50a796dcba2abe5f25c1e4cd8a69d7ea43343a8d (diff)
parent40ae1b9b618fbbc3b494a896a9d074b74e414337 (diff)
downloadmariadb-git-abf9d35213ba482a3927651ddb98baa47aeb34fd.tar.gz
Merge branch 'mysql/5.5' into 5.5
Diffstat (limited to 'client')
-rw-r--r--client/mysql_plugin.c10
-rw-r--r--client/mysql_upgrade.c2
-rw-r--r--client/mysqlcheck.c2
-rw-r--r--client/mysqldump.c2
-rw-r--r--client/mysqlshow.c39
5 files changed, 34 insertions, 21 deletions
diff --git a/client/mysql_plugin.c b/client/mysql_plugin.c
index 99da157f8c6..bc9969c9b66 100644
--- a/client/mysql_plugin.c
+++ b/client/mysql_plugin.c
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -407,7 +407,7 @@ exit:
static void usage(void)
{
PRINT_VERSION;
- puts("Copyright (c) 2011, Oracle and/or its affiliates. "
+ puts("Copyright (c) 2011, 2015, Oracle and/or its affiliates. "
"All rights reserved.\n");
puts("Enable or disable plugins.");
printf("\nUsage: %s [options] <plugin> ENABLE|DISABLE\n\nOptions:\n",
@@ -758,6 +758,11 @@ static int check_options(int argc, char **argv, char *operation)
/* read the plugin config file and check for match against argument */
else
{
+ if (strlen(argv[i]) + 4 + 1 > FN_REFLEN)
+ {
+ fprintf(stderr, "ERROR: argument is too long.\n");
+ return 1;
+ }
strcpy(plugin_name, argv[i]);
strcpy(config_file, argv[i]);
strcat(config_file, ".ini");
@@ -849,6 +854,7 @@ static int process_options(int argc, char *argv[], char *operation)
if (opt_basedir[i-1] != FN_LIBCHAR || opt_basedir[i-1] != FN_LIBCHAR2)
{
char buff[FN_REFLEN];
+ memset(buff, 0, sizeof(buff));
strncpy(buff, opt_basedir, sizeof(buff) - 1);
#ifdef __WIN__
diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c
index d8ee8f0d911..0be8f91af59 100644
--- a/client/mysql_upgrade.c
+++ b/client/mysql_upgrade.c
@@ -1,6 +1,6 @@
/*
Copyright (c) 2006, 2013, Oracle and/or its affiliates.
- Copyright (c) 2010, 2013, Monty Program Ab.
+ Copyright (c) 2010, 2015, MariaDB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c
index 37ede5cac30..267d847aa52 100644
--- a/client/mysqlcheck.c
+++ b/client/mysqlcheck.c
@@ -1,6 +1,6 @@
/*
Copyright (c) 2001, 2011, Oracle and/or its affiliates.
- Copyright (c) 2010, 2011, Monty Program Ab.
+ Copyright (c) 2010, 2015, MariaDB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/client/mysqldump.c b/client/mysqldump.c
index cfd38e019ba..b3a58abd88d 100644
--- a/client/mysqldump.c
+++ b/client/mysqldump.c
@@ -1,6 +1,6 @@
/*
Copyright (c) 2000, 2013, Oracle and/or its affiliates.
- Copyright (c) 2010, 2013, Monty Program Ab.
+ Copyright (c) 2010, 2015, Monty Program Ab.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/client/mysqlshow.c b/client/mysqlshow.c
index 5bcdd911cfd..b4514f5a678 100644
--- a/client/mysqlshow.c
+++ b/client/mysqlshow.c
@@ -1,6 +1,6 @@
/*
- Copyright (c) 2000, 2012, Oracle and/or its affiliates.
- Copyright (c) 2010, 2012, Monty Program Ab
+ Copyright (c) 2000, 2015, Oracle and/or its affiliates.
+ Copyright (c) 2010, 2015, MariaDB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -369,7 +369,7 @@ list_dbs(MYSQL *mysql,const char *wild)
uint length, counter = 0;
ulong rowcount = 0L;
char tables[NAME_LEN+1], rows[NAME_LEN+1];
- char query[255];
+ char query[NAME_LEN + 100];
MYSQL_FIELD *field;
MYSQL_RES *result;
MYSQL_ROW row= NULL, rrow;
@@ -436,7 +436,8 @@ list_dbs(MYSQL *mysql,const char *wild)
MYSQL_ROW trow;
while ((trow = mysql_fetch_row(tresult)))
{
- sprintf(query,"SELECT COUNT(*) FROM `%s`",trow[0]);
+ my_snprintf(query, sizeof(query),
+ "SELECT COUNT(*) FROM `%s`", trow[0]);
if (!(mysql_query(mysql,query)))
{
MYSQL_RES *rresult;
@@ -492,7 +493,7 @@ list_tables(MYSQL *mysql,const char *db,const char *table)
{
const char *header;
uint head_length, counter = 0;
- char query[255], rows[NAME_LEN], fields[16];
+ char query[NAME_LEN + 100], rows[NAME_LEN], fields[16];
MYSQL_FIELD *field;
MYSQL_RES *result;
MYSQL_ROW row, rrow;
@@ -577,7 +578,8 @@ list_tables(MYSQL *mysql,const char *db,const char *table)
if (opt_verbose > 1)
{
/* Print the count of rows for each table */
- sprintf(query,"SELECT COUNT(*) FROM `%s`",row[0]);
+ my_snprintf(query, sizeof(query), "SELECT COUNT(*) FROM `%s`",
+ row[0]);
if (!(mysql_query(mysql,query)))
{
if ((rresult = mysql_store_result(mysql)))
@@ -637,13 +639,15 @@ list_tables(MYSQL *mysql,const char *db,const char *table)
static int
list_table_status(MYSQL *mysql,const char *db,const char *wild)
{
- char query[1024],*end;
+ char query[NAME_LEN + 100];
+ int len;
MYSQL_RES *result;
MYSQL_ROW row;
- end=strxmov(query,"show table status from `",db,"`",NullS);
- if (wild && wild[0])
- strxmov(end," like '",wild,"'",NullS);
+ len= sizeof(query);
+ len-= my_snprintf(query, len, "show table status from `%s`", db);
+ if (wild && wild[0] && len)
+ strxnmov(query + strlen(query), len, " like '", wild, "'", NullS);
if (mysql_query(mysql,query) || !(result=mysql_store_result(mysql)))
{
fprintf(stderr,"%s: Cannot get status for db: %s, table: %s: %s\n",
@@ -675,7 +679,8 @@ static int
list_fields(MYSQL *mysql,const char *db,const char *table,
const char *wild)
{
- char query[1024],*end;
+ char query[NAME_LEN + 100];
+ int len;
MYSQL_RES *result;
MYSQL_ROW row;
ulong UNINIT_VAR(rows);
@@ -689,7 +694,7 @@ list_fields(MYSQL *mysql,const char *db,const char *table,
if (opt_count)
{
- sprintf(query,"select count(*) from `%s`", table);
+ my_snprintf(query, sizeof(query), "select count(*) from `%s`", table);
if (mysql_query(mysql,query) || !(result=mysql_store_result(mysql)))
{
fprintf(stderr,"%s: Cannot get record count for db: %s, table: %s: %s\n",
@@ -701,9 +706,11 @@ list_fields(MYSQL *mysql,const char *db,const char *table,
mysql_free_result(result);
}
- end=strmov(strmov(strmov(query,"show /*!32332 FULL */ columns from `"),table),"`");
- if (wild && wild[0])
- strxmov(end," like '",wild,"'",NullS);
+ len= sizeof(query);
+ len-= my_snprintf(query, len, "show /*!32332 FULL */ columns from `%s`",
+ table);
+ if (wild && wild[0] && len)
+ strxnmov(query + strlen(query), len, " like '", wild, "'", NullS);
if (mysql_query(mysql,query) || !(result=mysql_store_result(mysql)))
{
fprintf(stderr,"%s: Cannot list columns in db: %s, table: %s: %s\n",
@@ -724,7 +731,7 @@ list_fields(MYSQL *mysql,const char *db,const char *table,
print_res_top(result);
if (opt_show_keys)
{
- end=strmov(strmov(strmov(query,"show keys from `"),table),"`");
+ my_snprintf(query, sizeof(query), "show keys from `%s`", table);
if (mysql_query(mysql,query) || !(result=mysql_store_result(mysql)))
{
fprintf(stderr,"%s: Cannot list keys in db: %s, table: %s: %s\n",