Skip to content

Commit 207dd71

Browse files
harinvadodariaHery Ramilison
authored andcommitted
Bug#27099029: UNLIMITED LENGTH OF THE PASSWORD
Post push fix: Handled missing cases of GRANT. (cherry picked from commit b7430c02d2e07ae5322c6e5caecc32db76170c2e)
1 parent 79b94a1 commit 207dd71

File tree

3 files changed

+27
-8
lines changed

3 files changed

+27
-8
lines changed

sql/auth/auth_common.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,8 @@ bool mysql_rename_user(THD *thd, List <LEX_USER> &list);
620620
bool set_and_validate_user_attributes(THD *thd,
621621
LEX_USER *Str,
622622
ulong &what_to_set,
623-
bool is_privileged_user);
623+
bool is_privileged_user,
624+
const char * cmd);
624625

625626
/* sql_auth_cache */
626627
int wild_case_compare(CHARSET_INFO *cs, const char *str,const char *wildstr);

sql/auth/sql_authorization.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,7 +1321,8 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list,
13211321
}
13221322

13231323
if (set_and_validate_user_attributes(thd, Str, what_to_set,
1324-
is_privileged_user))
1324+
is_privileged_user,
1325+
revoke_grant?"REVOKE":"GRANT"))
13251326
{
13261327
result= TRUE;
13271328
continue;
@@ -1636,7 +1637,8 @@ bool mysql_routine_grant(THD *thd, TABLE_LIST *table_list, bool is_proc,
16361637
}
16371638

16381639
if (set_and_validate_user_attributes(thd, Str, what_to_set,
1639-
is_privileged_user))
1640+
is_privileged_user,
1641+
revoke_grant?"REVOKE":"GRANT"))
16401642
{
16411643
result= TRUE;
16421644
continue;
@@ -1887,7 +1889,8 @@ bool mysql_grant(THD *thd, const char *db, List <LEX_USER> &list,
18871889
}
18881890

18891891
if (set_and_validate_user_attributes(thd, Str, what_to_set,
1890-
is_privileged_user))
1892+
is_privileged_user,
1893+
revoke_grant?"REVOKE":"GRANT"))
18911894
{
18921895
result= TRUE;
18931896
continue;

sql/auth/sql_user.cc

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,7 @@ bool mysql_show_create_user(THD *thd, LEX_USER *user_name)
397397
@param what_to_set User attributes
398398
@param is_privileged_user Whether caller has CREATE_USER_ACL
399399
or UPDATE_ACL over mysql.*
400+
@param cmd Command information
400401
401402
@retval 0 ok
402403
@retval 1 ERROR;
@@ -405,7 +406,8 @@ bool mysql_show_create_user(THD *thd, LEX_USER *user_name)
405406
bool set_and_validate_user_attributes(THD *thd,
406407
LEX_USER *Str,
407408
ulong &what_to_set,
408-
bool is_privileged_user)
409+
bool is_privileged_user,
410+
const char * cmd)
409411
{
410412
bool user_exists= false;
411413
ACL_USER *acl_user;
@@ -574,6 +576,17 @@ bool set_and_validate_user_attributes(THD *thd,
574576
inbuflen))
575577
{
576578
plugin_unlock(0, plugin);
579+
580+
/*
581+
generate_authentication_string may return error status
582+
without setting actual error.
583+
*/
584+
if (!thd->is_error())
585+
{
586+
String error_user;
587+
append_user(thd, &error_user, Str, FALSE, FALSE);
588+
my_error(ER_CANNOT_USER, MYF(0), cmd, error_user.c_ptr_safe());
589+
}
577590
return(1);
578591
}
579592
if (buflen)
@@ -759,7 +772,8 @@ bool change_password(THD *thd, const char *host, const char *user,
759772
thd->slave_thread)
760773
combo->uses_identified_by_clause= false;
761774

762-
if (set_and_validate_user_attributes(thd, combo, what_to_set, true))
775+
if (set_and_validate_user_attributes(thd, combo, what_to_set,
776+
true, "SET PASSWORD"))
763777
{
764778
result= 1;
765779
mysql_mutex_unlock(&acl_cache->lock);
@@ -1390,7 +1404,8 @@ bool mysql_create_user(THD *thd, List <LEX_USER> &list, bool if_not_exists)
13901404
result= TRUE;
13911405
continue;
13921406
}
1393-
if (set_and_validate_user_attributes(thd, user_name, what_to_update, true))
1407+
if (set_and_validate_user_attributes(thd, user_name, what_to_update,
1408+
true, "CREATE USER"))
13941409
{
13951410
result= TRUE;
13961411
continue;
@@ -1857,7 +1872,7 @@ bool mysql_alter_user(THD *thd, List <LEX_USER> &list, bool if_exists)
18571872
user_from->alter_status= thd->lex->alter_password;
18581873

18591874
if (set_and_validate_user_attributes(thd, user_from, what_to_alter,
1860-
is_privileged_user))
1875+
is_privileged_user, "ALTER USER"))
18611876
{
18621877
result= true;
18631878
continue;

0 commit comments

Comments
 (0)