diff options
author | Nirbhay Choubey <nirbhay@mariadb.com> | 2015-08-08 14:21:22 -0400 |
---|---|---|
committer | Nirbhay Choubey <nirbhay@mariadb.com> | 2015-08-08 14:21:22 -0400 |
commit | 91acc8b16fdd8409765f32b5453851366552a709 (patch) | |
tree | 18c04064e9fc127c5e477ec08613aae7baaab2ae /client | |
parent | 4c69dc8116950d6bf0b09bfbc31a86d89831a364 (diff) | |
parent | 0403790722e3941779ccea26e85fcd818e2320b5 (diff) | |
download | mariadb-git-91acc8b16fdd8409765f32b5453851366552a709.tar.gz |
Merge tag 'mariadb-10.0.21' into 10.0-galera
Diffstat (limited to 'client')
-rw-r--r-- | client/mysql_upgrade.c | 3 | ||||
-rw-r--r-- | client/mysqlimport.c | 7 | ||||
-rw-r--r-- | client/mysqlslap.c | 49 |
3 files changed, 49 insertions, 10 deletions
diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index 01744c6d73a..0b312ef5f2f 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -1100,7 +1100,7 @@ int main(int argc, char **argv) printf("This installation of MySQL is already upgraded to %s, " "use --force if you still need to run mysql_upgrade\n", MYSQL_SERVER_VERSION); - die(NULL); + goto end; } if (opt_version_check && check_version_match()) @@ -1129,6 +1129,7 @@ int main(int argc, char **argv) DBUG_ASSERT(phase == phases_total); +end: free_used_memory(); my_end(my_end_arg); exit(0); diff --git a/client/mysqlimport.c b/client/mysqlimport.c index 0d4ee549c4f..cf1df1e95d8 100644 --- a/client/mysqlimport.c +++ b/client/mysqlimport.c @@ -36,7 +36,7 @@ /* Global Thread counter */ -uint counter; +uint counter= 0; pthread_mutex_t counter_mutex; pthread_cond_t count_threshhold; @@ -489,6 +489,11 @@ static void safe_exit(int error, MYSQL *mysql) { if (error && ignore_errors) return; + + /* in multi-threaded mode protect from concurrent safe_exit's */ + if (counter) + pthread_mutex_lock(&counter_mutex); + if (mysql) mysql_close(mysql); diff --git a/client/mysqlslap.c b/client/mysqlslap.c index b67e409ef0b..f12ea4c2086 100644 --- a/client/mysqlslap.c +++ b/client/mysqlslap.c @@ -1,5 +1,6 @@ /* - Copyright (c) 2005, 2012, Oracle and/or its affiliates. + Copyright (c) 2005, 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 @@ -242,7 +243,7 @@ void print_conclusions_csv(conclusions *con); void generate_stats(conclusions *con, option_string *eng, stats *sptr); uint parse_comma(const char *string, uint **range); uint parse_delimiter(const char *script, statement **stmt, char delm); -uint parse_option(const char *origin, option_string **stmt, char delm); +int parse_option(const char *origin, option_string **stmt, char delm); static int drop_schema(MYSQL *mysql, const char *db); uint get_random_string(char *buf); static statement *build_table_string(void); @@ -1264,7 +1265,13 @@ get_options(int *argc,char ***argv) if (num_int_cols_opt) { option_string *str; - parse_option(num_int_cols_opt, &str, ','); + if(parse_option(num_int_cols_opt, &str, ',') == -1) + { + fprintf(stderr, "Invalid value specified for the option " + "'number-int-cols'\n"); + option_cleanup(str); + return 1; + } num_int_cols= atoi(str->string); if (str->option) num_int_cols_index= atoi(str->option); @@ -1275,7 +1282,13 @@ get_options(int *argc,char ***argv) if (num_char_cols_opt) { option_string *str; - parse_option(num_char_cols_opt, &str, ','); + if(parse_option(num_char_cols_opt, &str, ',') == -1) + { + fprintf(stderr, "Invalid value specified for the option " + "'number-char-cols'\n"); + option_cleanup(str); + return 1; + } num_char_cols= atoi(str->string); if (str->option) num_char_cols_index= atoi(str->option); @@ -1512,7 +1525,13 @@ get_options(int *argc,char ***argv) printf("Parsing engines to use.\n"); if (default_engine) - parse_option(default_engine, &engine_options, ','); + { + if(parse_option(default_engine, &engine_options, ',') == -1) + { + fprintf(stderr, "Invalid value specified for the option 'engine'\n"); + return 1; + } + } if (tty_password) opt_password= get_tty_password(NullS); @@ -1989,7 +2008,7 @@ end: DBUG_RETURN(0); } -uint +int parse_option(const char *origin, option_string **stmt, char delm) { char *retstr; @@ -2014,6 +2033,13 @@ parse_option(const char *origin, option_string **stmt, char delm) char buffer[HUGE_STRING_LENGTH]= ""; char *buffer_ptr; + /* + Return an error if the length of the any of the comma seprated value + exceeds HUGE_STRING_LENGTH. + */ + if ((size_t)(retstr - ptr) > HUGE_STRING_LENGTH) + return -1; + count++; strncpy(buffer, ptr, (size_t)(retstr - ptr)); /* @@ -2053,6 +2079,13 @@ parse_option(const char *origin, option_string **stmt, char delm) { char *origin_ptr; + /* + Return an error if the length of the any of the comma seprated value + exceeds HUGE_STRING_LENGTH. + */ + if (strlen(ptr) > HUGE_STRING_LENGTH) + return -1; + if ((origin_ptr= strchr(ptr, ':'))) { char *option_ptr; @@ -2063,13 +2096,13 @@ parse_option(const char *origin, option_string **stmt, char delm) option_ptr= (char *)ptr + 1 + tmp->length; /* Move past the : and the first string */ - tmp->option_length= (size_t)((ptr + length) - option_ptr); + tmp->option_length= strlen(option_ptr); tmp->option= my_strndup(option_ptr, tmp->option_length, MYF(MY_FAE)); } else { - tmp->length= (size_t)((ptr + length) - ptr); + tmp->length= strlen(ptr); tmp->string= my_strndup(ptr, tmp->length, MYF(MY_FAE)); } |