summaryrefslogtreecommitdiff
path: root/sql
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
parent8751aa7397b2e698fa0b46ec3e60abb9e2fd7e1b (diff)
downloadmariadb-git-bb-10.6-MDEV-24312.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')
-rw-r--r--sql/event_db_repository.cc2
-rw-r--r--sql/hostname.cc7
-rw-r--r--sql/item_strfunc.cc2
-rw-r--r--sql/sp.cc2
-rw-r--r--sql/sql_acl.cc4
-rw-r--r--sql/sql_acl_getsort.ic29
-rw-r--r--sql/sql_class.cc13
-rw-r--r--sql/sql_class.h1
-rw-r--r--sql/sql_const.h2
9 files changed, 45 insertions, 17 deletions
diff --git a/sql/event_db_repository.cc b/sql/event_db_repository.cc
index a11f7adb9dd..4d3e6ba6ca1 100644
--- a/sql/event_db_repository.cc
+++ b/sql/event_db_repository.cc
@@ -57,7 +57,7 @@ const TABLE_FIELD_TYPE event_table_fields[ET_FIELD_COUNT] =
},
{
{ STRING_WITH_LEN("definer") },
- { STRING_WITH_LEN("char(") },
+ { STRING_WITH_LEN("varchar(") },
{ STRING_WITH_LEN("utf8") }
},
{
diff --git a/sql/hostname.cc b/sql/hostname.cc
index edf31c11081..fed47e88597 100644
--- a/sql/hostname.cc
+++ b/sql/hostname.cc
@@ -554,6 +554,13 @@ int ip_to_hostname(struct sockaddr_storage *ip_storage,
}
);
+ DBUG_EXECUTE_IF("getnameinfo_fake_long_host",
+ {
+ strcpy(hostname_buffer, "host5678901_345678902_345678903_345678904_345678905_345678906_345678907_345678908_345678909_345678910_345678911_345678912_345678913_345678914_345678915_345678916_345678917_345678918_345678919_345678920_345678921_345678922_345678923_345678924_345678925_345");
+ err_code= 0;
+ }
+ );
+
/*
===========================================================================
DEBUG code only (end)
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index b4f706984a5..5a6cb1a4c8f 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -55,7 +55,7 @@ C_MODE_END
#include <sql_repl.h>
#include "sql_statistics.h"
-size_t username_char_length= 80;
+size_t username_char_length= USERNAME_CHAR_LENGTH;
/*
Calculate max length of string from length argument to LEFT and RIGHT
diff --git a/sql/sp.cc b/sql/sp.cc
index 46494fb2393..ac9203ffb8a 100644
--- a/sql/sp.cc
+++ b/sql/sp.cc
@@ -177,7 +177,7 @@ TABLE_FIELD_TYPE proc_table_fields[MYSQL_PROC_FIELD_COUNT] =
},
{
{ STRING_WITH_LEN("definer") },
- { STRING_WITH_LEN("char(") },
+ { STRING_WITH_LEN("varchar(") },
{ STRING_WITH_LEN("utf8") }
},
{
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index a8e86e5f90f..5aa2a101822 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -64,8 +64,8 @@ bool using_global_priv_table= true;
// set that from field length in acl_load?
#ifndef NO_EMBEDDED_ACCESS_CHECKS
-const uint max_hostname_length= 60;
-const uint max_dbname_length= 64;
+const uint max_hostname_length= HOSTNAME_LENGTH;
+const uint max_dbname_length= NAME_CHAR_LEN;
#endif
const char *safe_vio_type_name(Vio *vio)
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);
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 7e5cffabffd..2fd07cef649 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -4720,6 +4720,19 @@ extern "C" void thd_create_random_password(MYSQL_THD thd,
}
+extern "C" const char *thd_priv_host(MYSQL_THD thd, size_t *length)
+{
+ const Security_context *sctx= thd->security_ctx;
+ if (!sctx)
+ {
+ *length= 0;
+ return NULL;
+ }
+ *length= strlen(sctx->priv_host);
+ return sctx->priv_host;
+}
+
+
#ifdef INNODB_COMPATIBILITY_HOOKS
/** open a table and add it to thd->open_tables
diff --git a/sql/sql_class.h b/sql/sql_class.h
index f001f14c219..0de1d74ec69 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -197,6 +197,7 @@ extern MYSQL_PLUGIN_IMPORT const char **errmesg;
extern "C" LEX_STRING * thd_query_string (MYSQL_THD thd);
extern "C" unsigned long long thd_query_id(const MYSQL_THD thd);
extern "C" size_t thd_query_safe(MYSQL_THD thd, char *buf, size_t buflen);
+extern "C" const char *thd_priv_host(MYSQL_THD thd, size_t *length);
extern "C" const char *thd_user_name(MYSQL_THD thd);
extern "C" const char *thd_client_host(MYSQL_THD thd);
extern "C" const char *thd_client_ip(MYSQL_THD thd);
diff --git a/sql/sql_const.h b/sql/sql_const.h
index 3f053a1606d..762728aa876 100644
--- a/sql/sql_const.h
+++ b/sql/sql_const.h
@@ -49,7 +49,7 @@
#else
#define MAX_REFLENGTH 4 /* Max length for record ref */
#endif
-#define MAX_HOSTNAME 61 /* len+1 in mysql.user */
+#define MAX_HOSTNAME (HOSTNAME_LENGTH + 1) /* len+1 in mysql.user */
#define MAX_CONNECTION_NAME NAME_LEN
#define MAX_MBWIDTH 3 /* Max multibyte sequence */