Commit 92bb23e2 authored by unknown's avatar unknown

bug #928 - arbitrary table grant was used, sort-order wasn't honored

parent 16969a48
...@@ -1204,6 +1204,7 @@ class GRANT_TABLE :public Sql_alloc ...@@ -1204,6 +1204,7 @@ class GRANT_TABLE :public Sql_alloc
public: public:
char *host,*db,*user,*tname, *hash_key; char *host,*db,*user,*tname, *hash_key;
uint privs, cols, key_length; uint privs, cols, key_length;
ulong sort;
HASH hash_columns; HASH hash_columns;
GRANT_TABLE (const char *h, const char *d,const char *u, const char *t, GRANT_TABLE (const char *h, const char *d,const char *u, const char *t,
uint p,uint c) uint p,uint c)
...@@ -1212,6 +1213,7 @@ public: ...@@ -1212,6 +1213,7 @@ public:
host = strdup_root(&memex,h); host = strdup_root(&memex,h);
db = strdup_root(&memex,d); db = strdup_root(&memex,d);
user = strdup_root(&memex,u); user = strdup_root(&memex,u);
sort= get_sort(3,host,db,user);
tname= strdup_root(&memex,t); tname= strdup_root(&memex,t);
key_length =(uint) strlen(d)+(uint) strlen(u)+(uint) strlen(t)+3; key_length =(uint) strlen(d)+(uint) strlen(u)+(uint) strlen(t)+3;
hash_key = (char*) alloc_root(&memex,key_length); hash_key = (char*) alloc_root(&memex,key_length);
...@@ -1227,6 +1229,7 @@ public: ...@@ -1227,6 +1229,7 @@ public:
host = get_field(&memex,form,0); host = get_field(&memex,form,0);
db = get_field(&memex,form,1); db = get_field(&memex,form,1);
user = get_field(&memex,form,2); if (!user) user=(char*) ""; user = get_field(&memex,form,2); if (!user) user=(char*) "";
sort= get_sort(3,host,db,user);
tname = get_field(&memex,form,3); tname = get_field(&memex,form,3);
if (!host || !db || !tname) if (!host || !db || !tname)
{ {
...@@ -1324,9 +1327,10 @@ static GRANT_TABLE *table_hash_search(const char *host,const char* ip, ...@@ -1324,9 +1327,10 @@ static GRANT_TABLE *table_hash_search(const char *host,const char* ip,
} }
else else
{ {
if ((host && !wild_case_compare(host,grant_table->host)) || if (((host && !wild_case_compare(host,grant_table->host)) ||
(ip && !wild_case_compare(ip,grant_table->host))) (ip && !wild_case_compare(ip,grant_table->host))) &&
found=grant_table; // Host ok (!found || found->sort < grant_table->sort))
found=grant_table;
} }
} }
return found; return found;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment