diff options
Diffstat (limited to 'sql')
-rw-r--r-- | sql/mysql_priv.h | 2 | ||||
-rw-r--r-- | sql/slave.h | 2 | ||||
-rw-r--r-- | sql/sp.cc | 8 | ||||
-rw-r--r-- | sql/sp_head.cc | 6 | ||||
-rw-r--r-- | sql/sql_acl.cc | 12 | ||||
-rw-r--r-- | sql/sql_class.h | 2 | ||||
-rw-r--r-- | sql/sql_parse.cc | 17 | ||||
-rw-r--r-- | sql/sql_repl.h | 2 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 6 | ||||
-rw-r--r-- | sql/table.cc | 6 |
10 files changed, 30 insertions, 33 deletions
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 5bf37d6b5f7..e15466eec9f 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -578,7 +578,7 @@ void get_default_definer(THD *thd, LEX_USER *definer); LEX_USER *create_default_definer(THD *thd); LEX_USER *create_definer(THD *thd, LEX_STRING *user_name, LEX_STRING *host_name); LEX_USER *get_current_user(THD *thd, LEX_USER *user); -bool check_string_length(CHARSET_INFO *cs, LEX_STRING *str, +bool check_string_length(LEX_STRING *str, const char *err_msg, uint max_length); enum enum_mysql_completiontype { diff --git a/sql/slave.h b/sql/slave.h index dee134aaa0c..c355f7172a9 100644 --- a/sql/slave.h +++ b/sql/slave.h @@ -406,7 +406,7 @@ typedef struct st_master_info /* the variables below are needed because we can change masters on the fly */ char master_log_name[FN_REFLEN]; char host[HOSTNAME_LENGTH+1]; - char user[USERNAME_BYTE_LENGTH+1]; + char user[USERNAME_LENGTH+1]; char password[MAX_PASSWORD_LENGTH+1]; my_bool ssl; // enables use of SSL connection if true char ssl_ca[FN_REFLEN], ssl_capath[FN_REFLEN], ssl_cert[FN_REFLEN]; diff --git a/sql/sp.cc b/sql/sp.cc index 63175b110fa..fc72822c15e 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -404,16 +404,16 @@ db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp, { LEX *old_lex= thd->lex, newlex; String defstr; - char old_db_buf[NAME_BYTE_LEN+1]; + char old_db_buf[NAME_LEN+1]; LEX_STRING old_db= { old_db_buf, sizeof(old_db_buf) }; bool dbchanged; ulong old_sql_mode= thd->variables.sql_mode; ha_rows old_select_limit= thd->variables.select_limit; sp_rcontext *old_spcont= thd->spcont; - char definer_user_name_holder[USERNAME_BYTE_LENGTH + 1]; + char definer_user_name_holder[USERNAME_LENGTH + 1]; LEX_STRING_WITH_INIT definer_user_name(definer_user_name_holder, - USERNAME_BYTE_LENGTH); + USERNAME_LENGTH); char definer_host_name_holder[HOSTNAME_LENGTH + 1]; LEX_STRING_WITH_INIT definer_host_name(definer_host_name_holder, @@ -511,7 +511,7 @@ db_create_routine(THD *thd, int type, sp_head *sp) int ret; TABLE *table; char definer[USER_HOST_BUFF_SIZE]; - char old_db_buf[NAME_BYTE_LEN+1]; + char old_db_buf[NAME_LEN+1]; LEX_STRING old_db= { old_db_buf, sizeof(old_db_buf) }; bool dbchanged; DBUG_ENTER("db_create_routine"); diff --git a/sql/sp_head.cc b/sql/sp_head.cc index e5b0b1e606e..9761de625be 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -924,7 +924,7 @@ bool sp_head::execute(THD *thd) { DBUG_ENTER("sp_head::execute"); - char old_db_buf[NAME_BYTE_LEN+1]; + char old_db_buf[NAME_LEN+1]; LEX_STRING old_db= { old_db_buf, sizeof(old_db_buf) }; bool dbchanged; sp_rcontext *ctx; @@ -1957,8 +1957,8 @@ sp_head::set_info(longlong created, longlong modified, void sp_head::set_definer(const char *definer, uint definerlen) { - char user_name_holder[USERNAME_BYTE_LENGTH + 1]; - LEX_STRING_WITH_INIT user_name(user_name_holder, USERNAME_BYTE_LENGTH); + char user_name_holder[USERNAME_LENGTH + 1]; + LEX_STRING_WITH_INIT user_name(user_name_holder, USERNAME_LENGTH); char host_name_holder[HOSTNAME_LENGTH + 1]; LEX_STRING_WITH_INIT host_name(host_name_holder, HOSTNAME_LENGTH); diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 010a5c33b96..e6170cae994 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -54,7 +54,7 @@ static byte* acl_entry_get_key(acl_entry *entry,uint *length, } #define IP_ADDR_STRLEN (3+1+3+1+3+1+3) -#define ACL_KEY_LENGTH (IP_ADDR_STRLEN+1+NAME_BYTE_LEN+1+USERNAME_BYTE_LENGTH+1) +#define ACL_KEY_LENGTH (IP_ADDR_STRLEN+1+NAME_LEN+1+USERNAME_LENGTH+1) static DYNAMIC_ARRAY acl_hosts,acl_users,acl_dbs; static MEM_ROOT mem, memex; @@ -197,7 +197,7 @@ static my_bool acl_load(THD *thd, TABLE_LIST *tables) READ_RECORD read_record_info; my_bool return_val= 1; bool check_no_resolve= specialflag & SPECIAL_NO_RESOLVE; - char tmp_name[NAME_BYTE_LEN+1]; + char tmp_name[NAME_LEN+1]; int password_length; DBUG_ENTER("acl_load"); @@ -2264,7 +2264,7 @@ static GRANT_NAME *name_hash_search(HASH *name_hash, const char *user, const char *tname, bool exact) { - char helping [NAME_BYTE_LEN*2+USERNAME_BYTE_LENGTH+3]; + char helping [NAME_LEN*2+USERNAME_LENGTH+3]; uint len; GRANT_NAME *grant_name,*found=0; HASH_SEARCH_STATE state; @@ -3167,7 +3167,7 @@ bool mysql_grant(THD *thd, const char *db, List <LEX_USER> &list, { List_iterator <LEX_USER> str_list (list); LEX_USER *Str, *tmp_Str; - char tmp_db[NAME_BYTE_LEN+1]; + char tmp_db[NAME_LEN+1]; bool create_new_users=0; TABLE_LIST tables[2]; DBUG_ENTER("mysql_grant"); @@ -3231,7 +3231,7 @@ bool mysql_grant(THD *thd, const char *db, List <LEX_USER> &list, { result= TRUE; continue; - } + } if (replace_user_table(thd, tables[0].table, *Str, (!db ? rights : 0), revoke_grant, create_new_users, test(thd->variables.sql_mode & @@ -3867,7 +3867,7 @@ err2: bool check_grant_db(THD *thd,const char *db) { Security_context *sctx= thd->security_ctx; - char helping [NAME_BYTE_LEN+USERNAME_BYTE_LENGTH+2]; + char helping [NAME_LEN+USERNAME_LENGTH+2]; uint len; bool error= 1; diff --git a/sql/sql_class.h b/sql/sql_class.h index ed9f4b57f56..039c133e885 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -200,7 +200,7 @@ class MYSQL_LOG: public TC_LOG IO_CACHE log_file; IO_CACHE index_file; char *name; - char time_buff[20],db[NAME_BYTE_LEN+1]; + char time_buff[20],db[NAME_LEN+1]; char log_file_name[FN_REFLEN],index_file_name[FN_REFLEN]; /* The max size before rotation (usable only if log_type == LOG_BIN: binary diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index ddd39bd1c9e..18d048df393 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1001,8 +1001,8 @@ static int check_connection(THD *thd) char *passwd= strend(user)+1; uint user_len= passwd - user - 1; char *db= passwd; - char db_buff[NAME_BYTE_LEN + 1]; // buffer to store db in utf8 - char user_buff[USERNAME_BYTE_LENGTH + 1]; // buffer to store user in utf8 + char db_buff[NAME_LEN + 1]; // buffer to store db in utf8 + char user_buff[USERNAME_LENGTH + 1]; // buffer to store user in utf8 uint dummy_errors; /* @@ -1662,7 +1662,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, password. New clients send the size (1 byte) + string (not null terminated, so also '\0' for empty string). */ - char db_buff[NAME_BYTE_LEN+1]; // buffer to store db in utf8 + char db_buff[NAME_LEN+1]; // buffer to store db in utf8 char *db= passwd; uint passwd_len= thd->client_capabilities & CLIENT_SECURE_CONNECTION ? *passwd++ : strlen(passwd); @@ -7565,7 +7565,6 @@ LEX_USER *get_current_user(THD *thd, LEX_USER *user) SYNOPSIS check_string_length() - cs string charset str string to be checked err_msg error message to be displayed if the string is too long max_length max length @@ -7575,13 +7574,13 @@ LEX_USER *get_current_user(THD *thd, LEX_USER *user) TRUE the passed string is longer than max_length */ -bool check_string_length(CHARSET_INFO *cs, LEX_STRING *str, - const char *err_msg, uint max_length) +bool check_string_length(LEX_STRING *str, const char *err_msg, + uint max_length) { - if (cs->cset->charpos(cs, str->str, str->str + str->length, - max_length) >= str->length) - return FALSE; + if (str->length <= max_length) + return FALSE; my_error(ER_WRONG_STRING_LENGTH, MYF(0), str->str, err_msg, max_length); + return TRUE; } diff --git a/sql/sql_repl.h b/sql/sql_repl.h index 6b1e5e6b447..9eb6456ee20 100644 --- a/sql/sql_repl.h +++ b/sql/sql_repl.h @@ -22,7 +22,7 @@ typedef struct st_slave_info uint32 server_id; uint32 rpl_recovery_rank, master_id; char host[HOSTNAME_LENGTH+1]; - char user[USERNAME_BYTE_LENGTH+1]; + char user[USERNAME_LENGTH+1]; char password[MAX_PASSWORD_LENGTH+1]; uint16 port; THD* thd; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 32f618e9601..764b6dd53c1 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -7523,7 +7523,7 @@ user: $$->host.str= (char *) "%"; $$->host.length= 1; - if (check_string_length(system_charset_info, &$$->user, + if (check_string_length(&$$->user, ER(ER_USERNAME), USERNAME_LENGTH)) YYABORT; } @@ -7534,9 +7534,9 @@ user: YYABORT; $$->user = $1; $$->host=$3; - if (check_string_length(system_charset_info, &$$->user, + if (check_string_length(&$$->user, ER(ER_USERNAME), USERNAME_LENGTH) || - check_string_length(&my_charset_latin1, &$$->host, + check_string_length(&$$->host, ER(ER_HOSTNAME), HOSTNAME_LENGTH)) YYABORT; } diff --git a/sql/table.cc b/sql/table.cc index 054736401ff..1886fdb0b82 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -1592,7 +1592,7 @@ char *get_field(MEM_ROOT *mem, Field *field) bool check_db_name(char *name) { - uint name_length= 0; // name length in symbols + char *start= name; /* Used to catch empty names and names with end space */ bool last_char_is_space= TRUE; @@ -1609,7 +1609,6 @@ bool check_db_name(char *name) name+system_charset_info->mbmaxlen); if (len) { - name_length++; name += len; continue; } @@ -1617,13 +1616,12 @@ bool check_db_name(char *name) #else last_char_is_space= *name==' '; #endif - name_length++; if (*name == '/' || *name == '\\' || *name == FN_LIBCHAR || *name == FN_EXTCHAR) return 1; name++; } - return (last_char_is_space || name_length > NAME_LEN); + return last_char_is_space || (uint) (name - start) > NAME_LEN; } |