summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2016-05-30 21:42:36 +0300
committerVicențiu Ciorbaru <vicentiu@mariadb.org>2016-06-22 16:41:38 +0300
commit5fd80875909c88e624a79a528eaaf9418089a211 (patch)
treeafd33a7875e89093c3e0dda75d16c04c310b87c5 /sql
parentf9b5acfb0cdf175e3f2ab555cf082b1ef4b920a9 (diff)
downloadmariadb-git-5fd80875909c88e624a79a528eaaf9418089a211.tar.gz
[MDEV-9614] Roles and Users longer than 6 characters
The bug is apparent when the username is longer than the rolename. It is caused by a simple typo that caused a memcmp call to compare a different number of bytes than necessary. The fix was proposed by Igor Pashev. I have reviewed it and it is the correct approach. Test case introduced by me, using the details provided in the MDEV. Signed-off-by: Vicențiu Ciorbaru <vicentiu@mariadb.org>
Diffstat (limited to 'sql')
-rw-r--r--sql/sql_acl.cc12
1 files changed, 5 insertions, 7 deletions
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 8cc9469cd09..f06e9ce647c 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -7195,8 +7195,7 @@ bool check_grant_db(THD *thd, const char *db)
len= (uint) (end - helping) + 1;
/*
- If a role is set, we need to check for privileges
- here aswell
+ If a role is set, we need to check for privileges here as well.
*/
if (sctx->priv_role[0])
{
@@ -7210,11 +7209,10 @@ bool check_grant_db(THD *thd, const char *db)
for (uint idx=0 ; idx < column_priv_hash.records ; idx++)
{
- GRANT_TABLE *grant_table= (GRANT_TABLE*)
- my_hash_element(&column_priv_hash,
- idx);
+ GRANT_TABLE *grant_table= (GRANT_TABLE*) my_hash_element(&column_priv_hash,
+ idx);
if (len < grant_table->key_length &&
- !memcmp(grant_table->hash_key,helping,len) &&
+ !memcmp(grant_table->hash_key, helping, len) &&
compare_hostname(&grant_table->host, sctx->host, sctx->ip))
{
error= FALSE; /* Found match. */
@@ -7222,7 +7220,7 @@ bool check_grant_db(THD *thd, const char *db)
}
if (sctx->priv_role[0] &&
len2 < grant_table->key_length &&
- !memcmp(grant_table->hash_key,helping2,len) &&
+ !memcmp(grant_table->hash_key, helping2, len2) &&
(!grant_table->host.hostname || !grant_table->host.hostname[0]))
{
error= FALSE; /* Found role match */