summaryrefslogtreecommitdiff
path: root/sql/sql_acl_getsort.ic
diff options
context:
space:
mode:
authorOleksandr Byelkin <sanja@mariadb.com>2020-11-18 16:04:57 +0100
committerOleksandr Byelkin <sanja@mariadb.com>2021-04-20 16:36:56 +0200
commita3099a3b4a394da360b5c1e7ae6dc985ae2f7f2f (patch)
tree6df02d372d1ad80d3358122a9cff7961aa362775 /sql/sql_acl_getsort.ic
parent8751aa7397b2e698fa0b46ec3e60abb9e2fd7e1b (diff)
downloadmariadb-git-a3099a3b4a394da360b5c1e7ae6dc985ae2f7f2f.tar.gz
MDEV-24312 master_host has 60 character limit, increase to 255 bytesbb-10.6-MDEV-24312
Also increase user name up to 128. The work was started by Rucha Deodhar <rucha.deodhar@mariadb.com>, contains audit plugin fixes by Alexey Botchkov <holyfoot@askmonty.org>.
Diffstat (limited to 'sql/sql_acl_getsort.ic')
-rw-r--r--sql/sql_acl_getsort.ic29
1 files changed, 18 insertions, 11 deletions
diff --git a/sql/sql_acl_getsort.ic b/sql/sql_acl_getsort.ic
index df55c7c5f1e..046b412d5f6 100644
--- a/sql/sql_acl_getsort.ic
+++ b/sql/sql_acl_getsort.ic
@@ -14,6 +14,8 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
#ifndef NO_EMBEDDED_ACCESS_CHECKS
+
+#define magic_bits 30
/*
Returns a number which, if sorted in descending order, magically puts
patterns in the order from most specific (e.g. no wildcards) to most generic
@@ -21,8 +23,8 @@
Takes a template that lists types of following patterns (by the first letter
of _h_ostname, _d_bname, _u_sername) and up to four patterns.
- No more than two can be of 'h' or 'd' type (because one magic value takes 26
- bits, see below).
+ No more than two can be of 'h' or 'd' type (because one magic value takes
+ magic_bits bits, see below).
========================================================================
@@ -142,7 +144,7 @@
case 2: ((M*2*(maxlen+1) + L)*(maxlen+1) + K)*(maxlen+1) + P
upper bound: L<=maxlen, M<=maxlen, K<=maxlen/2, P<maxlen
- for a current maxlen=64, the magic number needs 26 bits.
+ for a current maxlen=64, the magic number needs magic_bits bits.
*/
static ulonglong get_magic_sort(const char *templ, ...)
@@ -165,9 +167,9 @@ static ulonglong get_magic_sort(const char *templ, ...)
continue;
}
- /* A wildcard pattern. Encoded in 26 bits. */
+ /* A wildcard pattern. Encoded in magic_bits bits. */
uint maxlen= *templ == 'd' ? max_dbname_length : max_hostname_length;
- DBUG_ASSERT(maxlen <= 64);
+ DBUG_ASSERT(maxlen <= 255);
DBUG_ASSERT(*templ == 'd' || *templ == 'h');
uint N= 0, M= 0, K= 0, P= 0;
@@ -189,14 +191,19 @@ static ulonglong get_magic_sort(const char *templ, ...)
if (pat[i] == wild_prefix && pat[i+1]) i++;
N++;
}
- uint L= K ? maxlen - N - M : 0, d= maxlen + 1, magic;
+
+ set_if_smaller(K, 31);
+ set_if_smaller(M, 31);
+
+ ulonglong L= K ? maxlen - N - M : 0, d= maxlen + 1, magic;
+ ulonglong d1= MY_MIN(d, 32);
if (L > M)
- magic= (((L * 2 + 1) * d + K) * d + M) * d + P;
+ magic= (((L * 2 + 1) * d + K) * d1 + M) * d + P;
else
- magic= (((M * 2 + 0) * d + L) * d + K) * d + P;
- DBUG_ASSERT(magic < 1<<26);
- sort= (sort << 26) + magic;
- IF_DBUG(bits_used+= 26,);
+ magic= (((M * 2 + 0) * d + L) * d1 + K) * d + P;
+ DBUG_ASSERT(magic < (1ULL << magic_bits));
+ sort= (sort << magic_bits) + magic;
+ IF_DBUG(bits_used+= magic_bits,);
}
DBUG_ASSERT(bits_used < 8*sizeof(sort));
va_end(args);