Browse Source

MDEV-4332 Increase username length from 16 characters

pull/843/head
Sergei Golubchik 13 years ago
parent
commit
84ce6832e6
  1. 2
      include/mysql_com.h
  2. 97
      mysql-test/r/grant_4332.result
  3. 2
      mysql-test/r/status_user.result
  4. 4
      mysql-test/suite/funcs_1/r/is_columns_is.result
  5. 4
      mysql-test/suite/funcs_1/r/is_columns_is_embedded.result
  6. 6
      mysql-test/suite/rpl/r/rpl_password_boundaries.result
  7. 2
      mysql-test/suite/rpl/t/rpl_password_boundaries.test
  8. 107
      mysql-test/t/grant_4332.test
  9. 2
      sql/event_db_repository.cc
  10. 2
      sql/item_strfunc.cc
  11. 6
      sql/item_strfunc.h
  12. 2
      sql/rpl_mi.h
  13. 2
      sql/sp.cc
  14. 6
      sql/sql_acl.cc
  15. 16
      sql/sql_repl.cc
  16. 2
      sql/sql_show.cc
  17. 4
      sql/sql_yacc.yy
  18. 9
      tests/mysql_client_test.c

2
include/mysql_com.h

@ -24,7 +24,7 @@
#define HOSTNAME_LENGTH 60
#define SYSTEM_CHARSET_MBMAXLEN 3
#define NAME_CHAR_LEN 64 /* Field/table name length */
#define USERNAME_CHAR_LENGTH 16
#define USERNAME_CHAR_LENGTH 128
#define NAME_LEN (NAME_CHAR_LEN*SYSTEM_CHARSET_MBMAXLEN)
#define USERNAME_LENGTH (USERNAME_CHAR_LENGTH*SYSTEM_CHARSET_MBMAXLEN)

97
mysql-test/r/grant_4332.result

@ -0,0 +1,97 @@
set global event_scheduler = on;
select user();
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def user() 253 77 14 N 1 31 8
user()
root@localhost
create user a17aaaaaaaaaaaaa0@localhost;
ERROR HY000: String 'a17aaaaaaaaaaaaa0' is too long for user name (should be no longer than 16)
alter table mysql.user modify User char(80) binary not null default '';
alter table mysql.db modify User char(80) binary not null default '';
alter table mysql.tables_priv modify User char(80) binary not null default '';
alter table mysql.columns_priv modify User char(80) binary not null default '';
alter table mysql.procs_priv modify User char(80) binary not null default '';
alter table mysql.proc modify definer char(141) collate utf8_bin not null default '';
alter table mysql.event modify definer char(141) collate utf8_bin not null default '';
flush privileges;
select user();
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def user() 253 141 14 N 1 31 8
user()
root@localhost
create user a17aaaaaaaaaaaaa0@localhost;
grant usage on *.* to a17aaaaaaaaaaaaa0@localhost;
grant select on mysql.user to b64bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb0@localhost;
grant select(User) on mysql.tables_priv to c80cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc0@localhost;
select user(), current_user();
user() current_user()
a17aaaaaaaaaaaaa0@localhost a17aaaaaaaaaaaaa0@localhost
show grants;
Grants for a17aaaaaaaaaaaaa0@localhost
GRANT USAGE ON *.* TO 'a17aaaaaaaaaaaaa0'@'localhost'
select user(), current_user();
user() current_user()
b64bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb0@localhost b64bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb0@localhost
show grants;
Grants for b64bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb0@localhost
GRANT USAGE ON *.* TO 'b64bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb0'@'localhost'
GRANT SELECT ON `mysql`.`user` TO 'b64bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb0'@'localhost'
select user,host from mysql.user where user like '%0';
user host
a17aaaaaaaaaaaaa0 localhost
b64bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb0 localhost
c80cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc0 localhost
select user,host from mysql.db;
ERROR 42000: SELECT command denied to user 'b64bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'@'localhost' for table 'db'
select user(), current_user();
user() current_user()
c80cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc0@localhost c80cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc0@localhost
show grants;
Grants for c80cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc0@localhost
GRANT USAGE ON *.* TO 'c80cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc0'@'localhost'
GRANT SELECT (User) ON `mysql`.`tables_priv` TO 'c80cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc0'@'localhost'
select user from mysql.tables_priv;
user
b64bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb0
c80cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc0
select user,host from mysql.tables_priv;
ERROR 42000: SELECT command denied to user 'c80ccccccccccccccccccccccccccccccccccccccccccccc'@'localhost' for column 'host' in table 'tables_priv'
create procedure test.p1() select user(), current_user(), user from mysql.tables_priv;
show create procedure test.p1;
Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
p1 CREATE DEFINER=`c80cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc0`@`localhost` PROCEDURE `p1`()
select user(), current_user(), user from mysql.tables_priv latin1 latin1_swedish_ci latin1_swedish_ci
create table test.t1 (a text);
create event e1 on schedule every 1 second
do insert test.t1 values (concat(user(), ' ', current_user()));
call test.p1();
user() current_user() user
root@localhost c80cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc0@localhost b64bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb0
root@localhost c80cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc0@localhost c80cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc0
select * from t1 limit 1;
a
event_scheduler@localhost c80cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc0@localhost
grant usage on *.* to d81ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd0@lodalhost;
ERROR HY000: String 'd81ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd' is too long for user name (should be no longer than 80)
drop user d81ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd0@lodalhost;
ERROR HY000: String 'd81ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd' is too long for user name (should be no longer than 80)
drop user c80cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc0@localhost;
drop user b64bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb0@localhost;
drop user a17aaaaaaaaaaaaa0@localhost;
set global event_scheduler = off;
drop event e1;
drop procedure test.p1;
drop table t1;
alter table mysql.user modify User char(16) binary not null default '';
alter table mysql.db modify User char(16) binary not null default '';
alter table mysql.tables_priv modify User char(16) binary not null default '';
alter table mysql.columns_priv modify User char(16) binary not null default '';
alter table mysql.procs_priv modify User char(16) binary not null default '';
alter table mysql.proc modify definer char(77) collate utf8_bin not null default '';
alter table mysql.event modify definer char(77) collate utf8_bin not null default '';
flush privileges;
select user();
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def user() 253 77 14 N 1 31 8
user()
root@localhost

2
mysql-test/r/status_user.result

@ -27,7 +27,7 @@ ACCESS_DENIED bigint(21) NO 0
EMPTY_QUERIES bigint(21) NO 0
show columns from information_schema.user_statistics;
Field Type Null Key Default Extra
USER varchar(48) NO
USER varchar(128) NO
TOTAL_CONNECTIONS int(11) NO 0
CONCURRENT_CONNECTIONS int(11) NO 0
CONNECTED_TIME int(11) NO 0

4
mysql-test/suite/funcs_1/r/is_columns_is.result

@ -398,7 +398,7 @@ def information_schema USER_STATISTICS ROWS_UPDATED 14 0 NO bigint NULL NULL 19
def information_schema USER_STATISTICS SELECT_COMMANDS 15 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select
def information_schema USER_STATISTICS TOTAL_CONNECTIONS 2 0 NO int NULL NULL 10 0 NULL NULL NULL int(11) select
def information_schema USER_STATISTICS UPDATE_COMMANDS 16 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select
def information_schema USER_STATISTICS USER 1 NO varchar 48 144 NULL NULL NULL utf8 utf8_general_ci varchar(48) select
def information_schema USER_STATISTICS USER 1 NO varchar 128 384 NULL NULL NULL utf8 utf8_general_ci varchar(128) select
def information_schema VIEWS CHARACTER_SET_CLIENT 9 NO varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32) select
def information_schema VIEWS CHECK_OPTION 5 NO varchar 8 24 NULL NULL NULL utf8 utf8_general_ci varchar(8) select
def information_schema VIEWS COLLATION_CONNECTION 10 NO varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32) select
@ -844,7 +844,7 @@ NULL information_schema TRIGGERS CREATED datetime NULL NULL NULL NULL datetime
3.0000 information_schema USER_PRIVILEGES TABLE_CATALOG varchar 512 1536 utf8 utf8_general_ci varchar(512)
3.0000 information_schema USER_PRIVILEGES PRIVILEGE_TYPE varchar 64 192 utf8 utf8_general_ci varchar(64)
3.0000 information_schema USER_PRIVILEGES IS_GRANTABLE varchar 3 9 utf8 utf8_general_ci varchar(3)
3.0000 information_schema USER_STATISTICS USER varchar 48 144 utf8 utf8_general_ci varchar(48)
3.0000 information_schema USER_STATISTICS USER varchar 128 384 utf8 utf8_general_ci varchar(128)
NULL information_schema USER_STATISTICS TOTAL_CONNECTIONS int NULL NULL NULL NULL int(11)
NULL information_schema USER_STATISTICS CONCURRENT_CONNECTIONS int NULL NULL NULL NULL int(11)
NULL information_schema USER_STATISTICS CONNECTED_TIME int NULL NULL NULL NULL int(11)

4
mysql-test/suite/funcs_1/r/is_columns_is_embedded.result

@ -399,7 +399,7 @@ def information_schema USER_STATISTICS ROWS_UPDATED 14 0 NO bigint NULL NULL 19
def information_schema USER_STATISTICS SELECT_COMMANDS 15 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21)
def information_schema USER_STATISTICS TOTAL_CONNECTIONS 2 0 NO int NULL NULL 10 0 NULL NULL NULL int(11)
def information_schema USER_STATISTICS UPDATE_COMMANDS 16 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21)
def information_schema USER_STATISTICS USER 1 NO varchar 48 144 NULL NULL NULL utf8 utf8_general_ci varchar(48)
def information_schema USER_STATISTICS USER 1 NO varchar 128 384 NULL NULL NULL utf8 utf8_general_ci varchar(128)
def information_schema VIEWS CHARACTER_SET_CLIENT 9 NO varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32)
def information_schema VIEWS CHECK_OPTION 5 NO varchar 8 24 NULL NULL NULL utf8 utf8_general_ci varchar(8)
def information_schema VIEWS COLLATION_CONNECTION 10 NO varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32)
@ -849,7 +849,7 @@ NULL information_schema TRIGGERS CREATED datetime NULL NULL NULL NULL datetime
3.0000 information_schema USER_PRIVILEGES TABLE_CATALOG varchar 512 1536 utf8 utf8_general_ci varchar(512)
3.0000 information_schema USER_PRIVILEGES PRIVILEGE_TYPE varchar 64 192 utf8 utf8_general_ci varchar(64)
3.0000 information_schema USER_PRIVILEGES IS_GRANTABLE varchar 3 9 utf8 utf8_general_ci varchar(3)
3.0000 information_schema USER_STATISTICS USER varchar 48 144 utf8 utf8_general_ci varchar(48)
3.0000 information_schema USER_STATISTICS USER varchar 128 384 utf8 utf8_general_ci varchar(128)
NULL information_schema USER_STATISTICS TOTAL_CONNECTIONS int NULL NULL NULL NULL int(11)
NULL information_schema USER_STATISTICS CONCURRENT_CONNECTIONS int NULL NULL NULL NULL int(11)
NULL information_schema USER_STATISTICS CONNECTED_TIME int NULL NULL NULL NULL int(11)

6
mysql-test/suite/rpl/r/rpl_password_boundaries.result

@ -24,10 +24,10 @@ set sql_log_bin=1;
include/stop_slave.inc
change master to master_user='rpl33',master_password='0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef!';
ERROR HY000: String '0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef012345' is too long for MASTER_PASSWORD (should be no longer than 96)
change master to master_user='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa';
ERROR HY000: String 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' is too long for MASTER_USER (should be no longer than 47)
change master to master_user='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa';
ERROR HY000: String 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' is too long for MASTER_USER (should be no longer than 128)
change master to master_host='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc';
ERROR HY000: String 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbb' is too long for MASTER_HOST (should be no longer than 180)
ERROR HY000: String 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbb' is too long for MASTER_HOST (should be no longer than 60)
[ on master ]
set sql_log_bin=0;
grant replication slave on *.* to rpl16cyr@127.0.0.1 identified by 'воттакойужпарольвоттакойужпарольвоттакойужпароль';

2
mysql-test/suite/rpl/t/rpl_password_boundaries.test

@ -53,7 +53,7 @@ change master to master_user='rpl33',master_password='0123456789abcdef0123456789
# Check also master_user and master_host
--error ER_WRONG_STRING_LENGTH
change master to master_user='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa';
change master to master_user='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa';
--error ER_WRONG_STRING_LENGTH
change master to master_host='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc';

107
mysql-test/t/grant_4332.test

@ -0,0 +1,107 @@
#
# MDEV-4332 Increase username length from 16 characters
#
# user names here have the pattern
# <letter><length><more letters>0
# where '0' at the end is the end-of-name marker
--source include/not_embedded.inc
set global event_scheduler = on;
--enable_metadata
select user();
--disable_metadata
--error ER_WRONG_STRING_LENGTH
create user a17aaaaaaaaaaaaa0@localhost;
alter table mysql.user modify User char(80) binary not null default '';
alter table mysql.db modify User char(80) binary not null default '';
alter table mysql.tables_priv modify User char(80) binary not null default '';
alter table mysql.columns_priv modify User char(80) binary not null default '';
alter table mysql.procs_priv modify User char(80) binary not null default '';
alter table mysql.proc modify definer char(141) collate utf8_bin not null default '';
alter table mysql.event modify definer char(141) collate utf8_bin not null default '';
flush privileges;
--enable_metadata
select user();
--disable_metadata
create user a17aaaaaaaaaaaaa0@localhost;
grant usage on *.* to a17aaaaaaaaaaaaa0@localhost;
grant select on mysql.user to b64bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb0@localhost;
grant select(User) on mysql.tables_priv to c80cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc0@localhost;
connect (a17,localhost,a17aaaaaaaaaaaaa0,,);
connect (b64,localhost,b64bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb0,,);
connect (c80,localhost,c80cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc0,,);
connection a17;
select user(), current_user();
show grants;
connection b64;
select user(), current_user();
show grants;
select user,host from mysql.user where user like '%0';
--error ER_TABLEACCESS_DENIED_ERROR
select user,host from mysql.db;
connection c80;
select user(), current_user();
show grants;
select user from mysql.tables_priv;
--error ER_COLUMNACCESS_DENIED_ERROR
select user,host from mysql.tables_priv;
create procedure test.p1() select user(), current_user(), user from mysql.tables_priv;
show create procedure test.p1;
create table test.t1 (a text);
create event e1 on schedule every 1 second
do insert test.t1 values (concat(user(), ' ', current_user()));
connection default;
call test.p1();
disconnect a17;
disconnect b64;
disconnect c80;
let $wait_timeout= 10;
let $wait_condition= SELECT 1 from t1;
--source include/wait_condition.inc
select * from t1 limit 1;
--error ER_WRONG_STRING_LENGTH
grant usage on *.* to d81ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd0@lodalhost;
--error ER_WRONG_STRING_LENGTH
drop user d81ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd0@lodalhost;
drop user c80cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc0@localhost;
drop user b64bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb0@localhost;
drop user a17aaaaaaaaaaaaa0@localhost;
set global event_scheduler = off;
drop event e1;
drop procedure test.p1;
drop table t1;
alter table mysql.user modify User char(16) binary not null default '';
alter table mysql.db modify User char(16) binary not null default '';
alter table mysql.tables_priv modify User char(16) binary not null default '';
alter table mysql.columns_priv modify User char(16) binary not null default '';
alter table mysql.procs_priv modify User char(16) binary not null default '';
alter table mysql.proc modify definer char(77) collate utf8_bin not null default '';
alter table mysql.event modify definer char(77) collate utf8_bin not null default '';
flush privileges;
--enable_metadata
select user();
--disable_metadata

2
sql/event_db_repository.cc

@ -55,7 +55,7 @@ const TABLE_FIELD_TYPE event_table_fields[ET_FIELD_COUNT] =
},
{
{ C_STRING_WITH_LEN("definer") },
{ C_STRING_WITH_LEN("char(77)") },
{ C_STRING_WITH_LEN("char(") },
{ C_STRING_WITH_LEN("utf8") }
},
{

2
sql/item_strfunc.cc

@ -59,6 +59,8 @@ C_MODE_START
#include "../mysys/my_static.h" // For soundex_map
C_MODE_END
size_t username_char_length= 16;
/**
@todo Remove this. It is not safe to use a shared String object.
*/

6
sql/item_strfunc.h

@ -25,6 +25,8 @@
#pragma interface /* gcc class implementation */
#endif
extern size_t username_char_length;
class MY_LOCALE;
class Item_str_func :public Item_func
@ -494,8 +496,8 @@ public:
bool fix_fields(THD *thd, Item **ref);
void fix_length_and_dec()
{
max_length= (USERNAME_LENGTH +
(HOSTNAME_LENGTH + 1) * SYSTEM_CHARSET_MBMAXLEN);
max_length= (username_char_length +
HOSTNAME_LENGTH + 1) * SYSTEM_CHARSET_MBMAXLEN;
}
const char *func_name() const { return "user"; }
const char *fully_qualified_func_name() const { return "user()"; }

2
sql/rpl_mi.h

@ -67,7 +67,7 @@ class Master_info : public Slave_reporting_capability
/* the variables below are needed because we can change masters on the fly */
char master_log_name[FN_REFLEN];
char host[HOSTNAME_LENGTH*SYSTEM_CHARSET_MBMAXLEN+1];
char user[USERNAME_LENGTH*+1];
char user[USERNAME_LENGTH+1];
char password[MAX_PASSWORD_LENGTH*SYSTEM_CHARSET_MBMAXLEN+1];
bool ssl; // enables use of SSL connection if true
char ssl_ca[FN_REFLEN], ssl_capath[FN_REFLEN], ssl_cert[FN_REFLEN];

2
sql/sp.cc

@ -114,7 +114,7 @@ TABLE_FIELD_TYPE proc_table_fields[MYSQL_PROC_FIELD_COUNT] =
},
{
{ C_STRING_WITH_LEN("definer") },
{ C_STRING_WITH_LEN("char(77)") },
{ C_STRING_WITH_LEN("char(") },
{ C_STRING_WITH_LEN("utf8") }
},
{

6
sql/sql_acl.cc

@ -828,6 +828,7 @@ static my_bool acl_load(THD *thd, TABLE_LIST *tables)
table->use_all_columns();
(void) my_init_dynamic_array(&acl_users,sizeof(ACL_USER),50,100);
username_char_length= min(table->field[1]->char_length(), USERNAME_CHAR_LENGTH);
password_length= table->field[2]->field_length /
table->field[2]->charset()->mbmaxlen;
if (password_length < SCRAMBLED_PASSWORD_CHAR_LENGTH_323)
@ -8626,14 +8627,15 @@ static ulong parse_client_handshake_packet(MPVIO_EXT *mpvio,
/*
Clip username to allowed length in characters (not bytes). This is
mostly for backward compatibility.
mostly for backward compatibility (to truncate long usernames, as
old 5.1 did)
*/
{
CHARSET_INFO *cs= system_charset_info;
int err;
user_len= (uint) cs->cset->well_formed_len(cs, user, user + user_len,
USERNAME_CHAR_LENGTH, &err);
username_char_length, &err);
user[user_len]= '\0';
}

16
sql/sql_repl.cc

@ -1555,14 +1555,15 @@ void kill_zombie_dump_threads(uint32 slave_server_id)
*/
static bool get_string_parameter(char *to, const char *from, size_t length,
const char *name)
const char *name, CHARSET_INFO *cs)
{
if (from) // Empty paramaters allowed
{
size_t from_length;
if ((from_length= strlen(from)) > length)
size_t from_length= strlen(from);
uint from_numchars= cs->cset->numchars(cs, from, from + from_length);
if (from_numchars > length / cs->mbmaxlen)
{
my_error(ER_WRONG_STRING_LENGTH, MYF(0), from, name, (int) length);
my_error(ER_WRONG_STRING_LENGTH, MYF(0), from, name, length / cs->mbmaxlen);
return 1;
}
memcpy(to, from, from_length+1);
@ -1662,11 +1663,12 @@ bool change_master(THD* thd, Master_info* mi)
DBUG_PRINT("info", ("master_log_pos: %lu", (ulong) mi->master_log_pos));
if (get_string_parameter(mi->host, lex_mi->host, sizeof(mi->host)-1,
"MASTER_HOST") ||
"MASTER_HOST", system_charset_info) ||
get_string_parameter(mi->user, lex_mi->user, sizeof(mi->user)-1,
"MASTER_USER") ||
"MASTER_USER", system_charset_info) ||
get_string_parameter(mi->password, lex_mi->password,
sizeof(mi->password)-1, "MASTER_PASSWORD"))
sizeof(mi->password)-1, "MASTER_PASSWORD",
&my_charset_bin))
{
ret= TRUE;
goto err;

2
sql/sql_show.cc

@ -7041,7 +7041,7 @@ struct schema_table_ref
ST_FIELD_INFO user_stats_fields_info[]=
{
{"USER", USERNAME_LENGTH, MYSQL_TYPE_STRING, 0, 0, "User", SKIP_OPEN_TABLE},
{"USER", USERNAME_CHAR_LENGTH, MYSQL_TYPE_STRING, 0, 0, "User", SKIP_OPEN_TABLE},
{"TOTAL_CONNECTIONS", MY_INT32_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Total_connections",SKIP_OPEN_TABLE},
{"CONCURRENT_CONNECTIONS", MY_INT32_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Concurrent_connections",SKIP_OPEN_TABLE},
{"CONNECTED_TIME", MY_INT32_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONG, 0, 0, "Connected_time",SKIP_OPEN_TABLE},

4
sql/sql_yacc.yy

@ -12887,7 +12887,7 @@ user:
$$->auth= empty_lex_str;
if (check_string_char_length(&$$->user, ER(ER_USERNAME),
USERNAME_CHAR_LENGTH,
username_char_length,
system_charset_info, 0))
MYSQL_YYABORT;
}
@ -12902,7 +12902,7 @@ user:
$$->auth= empty_lex_str;
if (check_string_char_length(&$$->user, ER(ER_USERNAME),
USERNAME_CHAR_LENGTH,
username_char_length,
system_charset_info, 0) ||
check_host_name(&$$->host))
MYSQL_YYABORT;

9
tests/mysql_client_test.c

@ -16903,13 +16903,14 @@ static void test_bug31418()
*/
#define LARGE_BUFFER_SIZE 2048
#define OLD_USERNAME_CHAR_LENGTH 16
static void test_bug31669()
{
int rc;
static char buff[LARGE_BUFFER_SIZE+1];
#ifndef EMBEDDED_LIBRARY
static char user[USERNAME_CHAR_LENGTH+1];
static char user[OLD_USERNAME_CHAR_LENGTH+1];
static char db[NAME_CHAR_LEN+1];
static char query[LARGE_BUFFER_SIZE*2];
#endif
@ -16946,7 +16947,7 @@ static void test_bug31669()
myquery(rc);
memset(user, 'b', sizeof(user));
user[USERNAME_CHAR_LENGTH]= 0;
user[OLD_USERNAME_CHAR_LENGTH]= 0;
memset(buff, 'c', sizeof(buff));
buff[LARGE_BUFFER_SIZE]= 0;
strxmov(query, "GRANT ALL PRIVILEGES ON *.* TO '", user, "'@'%' IDENTIFIED BY "
@ -16965,11 +16966,11 @@ static void test_bug31669()
rc= mysql_change_user(conn, user, buff, db);
DIE_UNLESS(!rc);
user[USERNAME_CHAR_LENGTH-1]= 'a';
user[OLD_USERNAME_CHAR_LENGTH-1]= 'a';
rc= mysql_change_user(conn, user, buff, db);
DIE_UNLESS(rc);
user[USERNAME_CHAR_LENGTH-1]= 'b';
user[OLD_USERNAME_CHAR_LENGTH-1]= 'b';
buff[LARGE_BUFFER_SIZE-1]= 'd';
rc= mysql_change_user(conn, user, buff, db);
DIE_UNLESS(rc);

Loading…
Cancel
Save