Below is the list of changes that have just been committed into a local
5.0 repository of alik. When alik does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.2204 06/06/28 18:05:37 anozdrin@stripped +15 -0
Fix for BUG#16899: Possible buffer overflow in handling of DEFINER-clause
sql/sql_trigger.cc
1.52 06/06/28 18:05:33 anozdrin@stripped +2 -2
Use new set_definer() prototype.
sql/sql_parse.cc
1.557 06/06/28 18:05:33 anozdrin@stripped +50 -7
Truncate user/host names in DEFINER-clause during parsing.
sql/sp_head.h
1.86 06/06/28 18:05:33 anozdrin@stripped +1 -1
Changed prototype.
sql/sp_head.cc
1.218 06/06/28 18:05:32 anozdrin@stripped +32 -3
Throw warnings if user and/or host names exceed limits.
sql/sp.cc
1.115 06/06/28 18:05:32 anozdrin@stripped +31 -3
Throw warnings if user and/or host names exceed limits.
sql/share/errmsg.txt
1.65 06/06/28 18:05:32 anozdrin@stripped +4 -0
Added new error messages.
sql-common/my_user.c
1.2 06/06/28 18:05:32 anozdrin@stripped +35 -9
parse_user() was modified to truncate user and/or host names
if they exceed limits.
mysql-test/t/view.test
1.148 06/06/28 18:05:32 anozdrin@stripped +32 -0
Added test for BUG#16899.
mysql-test/t/trigger.test
1.47 06/06/28 18:05:32 anozdrin@stripped +35 -0
Added test for BUG#16899.
mysql-test/t/sp.test
1.191 06/06/28 18:05:32 anozdrin@stripped +36 -0
Added test for BUG#16899.
mysql-test/r/view.result
1.162 06/06/28 18:05:32 anozdrin@stripped +27 -0
Updated result file.
mysql-test/r/trigger.result
1.42 06/06/28 18:05:32 anozdrin@stripped +20 -0
Updated result file.
mysql-test/r/sp.result
1.203 06/06/28 18:05:32 anozdrin@stripped +23 -0
Updated result file.
include/my_user.h
1.2 06/06/28 18:05:32 anozdrin@stripped +3 -1
parse_user() was changed to provide information whether
user and/or host names were truncated during parsing.
client/mysqldump.c
1.233 06/06/28 18:05:32 anozdrin@stripped +23 -6
Throw warnings if user and/or host names exceed limits.
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: anozdrin
# Host: booka.site
# Root: /home/alik/MySQL/devel/5.0-rt-bug20438-bug16899
--- 1.232/client/mysqldump.c 2006-06-26 18:15:36 +04:00
+++ 1.233/client/mysqldump.c 2006-06-28 18:05:32 +04:00
@@ -1949,15 +1949,29 @@ DELIMITER ;;\n");
we should check if we have this column before accessing it.
*/
- uint user_name_len;
+ uint user_name_len= USERNAME_LENGTH;
char user_name_str[USERNAME_LENGTH + 1];
char quoted_user_name_str[USERNAME_LENGTH * 2 + 3];
- uint host_name_len;
+ uint host_name_len= HOSTNAME_LENGTH;
char host_name_str[HOSTNAME_LENGTH + 1];
char quoted_host_name_str[HOSTNAME_LENGTH * 2 + 3];
+ bool user_name_truncated;
+ bool host_name_truncated;
+
parse_user(row[7], strlen(row[7]), user_name_str, &user_name_len,
- host_name_str, &host_name_len);
+ host_name_str, &host_name_len,
+ &user_name_truncated, &host_name_truncated);
+
+ if (user_name_truncated)
+ fprintf(stderr,
+ "Warning: the user name has been truncated to %d symbols\n",
+ (int) USERNAME_LENGTH);
+
+ if (host_name_truncated)
+ fprintf(stderr,
+ "Warning: the host name has been truncated to %d symbols\n",
+ (int) HOSTNAME_LENGTH);
fprintf(sql_file,
"/*!50017 DEFINER=%s@%s */ ",
@@ -3465,15 +3479,18 @@ static my_bool get_view_structure(char *
Surround it with !50013 comments
*/
{
- uint user_name_len;
+ uint user_name_len= USERNAME_LENGTH;
char user_name_str[USERNAME_LENGTH + 1];
char quoted_user_name_str[USERNAME_LENGTH * 2 + 3];
- uint host_name_len;
+ uint host_name_len= HOSTNAME_LENGTH;
char host_name_str[HOSTNAME_LENGTH + 1];
char quoted_host_name_str[HOSTNAME_LENGTH * 2 + 3];
+ bool user_name_truncated;
+ bool host_name_truncated;
parse_user(row[1], lengths[1], user_name_str, &user_name_len,
- host_name_str, &host_name_len);
+ host_name_str, &host_name_len,
+ &user_name_truncated, &host_name_truncated);
ptr= search_buf;
search_len=
--- 1.556/sql/sql_parse.cc 2006-06-28 03:11:09 +04:00
+++ 1.557/sql/sql_parse.cc 2006-06-28 18:05:33 +04:00
@@ -7473,7 +7473,9 @@ LEX_USER *create_default_definer(THD *th
/*
- Create definer with the given user and host names.
+ Create definer with the given user and host names. Truncate user and host
+ names if needed to be not longer than USERNAME_LENGTH and HOSTNAME_LENGTH
+ respectively.
SYNOPSIS
create_definer()
@@ -7484,20 +7486,61 @@ LEX_USER *create_default_definer(THD *th
RETURN
On success, return a valid pointer to the created and initialized
LEX_USER, which contains definer information.
- On error, return 0.
+ On error, return NULL.
*/
LEX_USER *create_definer(THD *thd, LEX_STRING *user_name, LEX_STRING *host_name)
{
LEX_USER *definer;
- /* Create and initialize. */
+ /* Create definer structure. */
- if (! (definer= (LEX_USER*) thd->alloc(sizeof(LEX_USER))))
- return 0;
+ if (!(definer= (LEX_USER*) thd->alloc(sizeof(LEX_USER))))
+ return NULL;
- definer->user= *user_name;
- definer->host= *host_name;
+ /* Process user name part. */
+
+ if (user_name->length > USERNAME_LENGTH)
+ {
+ if (!(definer->user.str= (char *) thd->alloc(USERNAME_LENGTH + 1)))
+ return NULL;
+
+ definer->user.length= strmake(definer->user.str, user_name->str,
+ USERNAME_LENGTH) -
+ definer->user.str;
+
+ push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
+ ER_USER_NAME_TRUNCATED,
+ ER(ER_USER_NAME_TRUNCATED),
+ USERNAME_LENGTH);
+ }
+ else
+ {
+ definer->user= *user_name;
+ }
+
+ /* Process host name part. */
+
+ if (host_name->length > HOSTNAME_LENGTH)
+ {
+ if (!(definer->host.str= (char *) thd->alloc(HOSTNAME_LENGTH + 1)))
+ return NULL;
+
+ definer->host.length= strmake(definer->host.str, host_name->str,
+ HOSTNAME_LENGTH) -
+ definer->host.str;
+
+ push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
+ ER_HOST_NAME_TRUNCATED,
+ ER(ER_HOST_NAME_TRUNCATED),
+ HOSTNAME_LENGTH);
+ }
+ else
+ {
+ definer->host= *host_name;
+ }
+
+ /* That's all. */
return definer;
}
--- 1.64/sql/share/errmsg.txt 2006-05-15 00:51:02 +04:00
+++ 1.65/sql/share/errmsg.txt 2006-06-28 18:05:32 +04:00
@@ -5619,3 +5619,7 @@ ER_NON_GROUPING_FIELD_USED 42000
eng "non-grouping field '%-.64s' is used in %-.64s clause"
ER_TABLE_CANT_HANDLE_SPKEYS
eng "The used table type doesn't support SPATIAL indexes"
+ER_USER_NAME_TRUNCATED
+ eng "The user name has been truncated to %d symbols"
+ER_HOST_NAME_TRUNCATED
+ eng "The host name has been truncated to %d symbols"
--- 1.1/include/my_user.h 2006-01-11 02:07:35 +03:00
+++ 1.2/include/my_user.h 2006-06-28 18:05:32 +04:00
@@ -28,7 +28,9 @@ C_MODE_START
void parse_user(const char *user_id_str, uint user_id_len,
char *user_name_str, uint *user_name_len,
- char *host_name_str, uint *host_name_len);
+ char *host_name_str, uint *host_name_len,
+ bool *user_name_truncated,
+ bool *host_name_truncated);
C_MODE_END
--- 1.1/sql-common/my_user.c 2006-01-11 02:07:35 +03:00
+++ 1.2/sql-common/my_user.c 2006-06-28 18:05:32 +04:00
@@ -22,20 +22,31 @@
Parse user value to user name and host name parts.
SYNOPSIS
- user_id_str [IN] User value string (the source).
- user_id_len [IN] Length of the user value.
- user_name_str [OUT] Buffer to store user name part.
- Must be not less than USERNAME_LENGTH + 1.
- user_name_len [OUT] A place to store length of the user name part.
- host_name_str [OUT] Buffer to store host name part.
- Must be not less than HOSTNAME_LENGTH + 1.
- host_name_len [OUT] A place to store length of the host name part.
+ user_id_str [IN] User value string (the source).
+ user_id_len [IN] Length of the user value.
+ user_name_str [OUT] Buffer to store user name part.
+ user_name_len [IN/OUT]
+ IN: Maximal possible length of the user name part.
+ OUT: A place to store length of the user name part.
+ host_name_str [OUT] Buffer to store host name part.
+ host_name_len [IN/OUT]
+ IN: Maximal possible length of the host name part.
+ OUT: A place to store length of the host name part.
+ user_name_truncated [OUT] TRUE if user name has been truncated;
+ FALSE otherwise.
+ host_name_truncated [OUT] TRUE if host name has been truncated;
+ FALSE otherwise.
*/
void parse_user(const char *user_id_str, uint user_id_len,
char *user_name_str, uint *user_name_len,
- char *host_name_str, uint *host_name_len)
+ char *host_name_str, uint *host_name_len,
+ bool *user_name_truncated,
+ bool *host_name_truncated)
{
+ *user_name_truncated= FALSE;
+ *host_name_truncated= FALSE;
+
char *p= strrchr(user_id_str, '@');
if (!p)
@@ -45,8 +56,23 @@ void parse_user(const char *user_id_str,
}
else
{
+ uint max_user_name_len= *user_name_len;
+ uint max_host_name_len= *host_name_len;
+
*user_name_len= p - user_id_str;
*host_name_len= user_id_len - *user_name_len - 1;
+
+ if (*user_name_len > max_user_name_len)
+ {
+ *user_name_truncated= TRUE;
+ *user_name_len= max_user_name_len;
+ }
+
+ if (*host_name_len > max_host_name_len)
+ {
+ *host_name_truncated= TRUE;
+ *host_name_len= max_host_name_len;
+ }
memcpy(user_name_str, user_id_str, *user_name_len);
memcpy(host_name_str, p + 1, *host_name_len);
--- 1.161/mysql-test/r/view.result 2006-06-01 09:55:39 +04:00
+++ 1.162/mysql-test/r/view.result 2006-06-28 18:05:32 +04:00
@@ -2736,3 +2736,30 @@ m e
1 b
DROP VIEW v1;
DROP TABLE IF EXISTS t1,t2;
+DROP TABLE IF EXISTS t1;
+DROP VIEW IF EXISTS v1;
+DROP VIEW IF EXISTS v2;
+CREATE TABLE t1(a INT, b INT);
+CREATE DEFINER=1234567890abcdefGHIKL@localhost
+VIEW v1 AS SELECT a FROM t1;
+Warnings:
+Note 1465 The user name has been truncated to 16 symbols
+Note 1449 There is no '1234567890abcdef'@'localhost' registered
+CREATE
DEFINER=some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY
+VIEW v2 AS SELECT b FROM t1;
+Warnings:
+Note 1466 The host name has been truncated to 60 symbols
+Note 1449 There is no
'some_user_name'@'1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij'
registered
+SHOW CREATE VIEW v1;
+View Create View
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`1234567890abcdef`@`localhost` SQL SECURITY DEFINER
VIEW `v1` AS select `t1`.`a` AS `a` from `t1`
+Warnings:
+Note 1449 There is no '1234567890abcdef'@'localhost' registered
+SHOW CREATE VIEW v2;
+View Create View
+v2 CREATE ALGORITHM=UNDEFINED
DEFINER=`some_user_name`@`1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij`
SQL SECURITY DEFINER VIEW `v2` AS select `t1`.`b` AS `b` from `t1`
+Warnings:
+Note 1449 There is no
'some_user_name'@'1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij'
registered
+DROP TABLE t1;
+DROP VIEW v1;
+DROP VIEW v2;
--- 1.147/mysql-test/t/view.test 2006-06-01 09:55:39 +04:00
+++ 1.148/mysql-test/t/view.test 2006-06-28 18:05:32 +04:00
@@ -2596,3 +2596,35 @@ SELECT * FROM t2;
DROP VIEW v1;
DROP TABLE IF EXISTS t1,t2;
+
+
+#
+# Test for BUG#16899: Possible buffer overflow in handling of DEFINER-clause.
+#
+
+# Prepare.
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP VIEW IF EXISTS v1;
+DROP VIEW IF EXISTS v2;
+--enable_warnings
+
+CREATE TABLE t1(a INT, b INT);
+
+CREATE DEFINER=1234567890abcdefGHIKL@localhost
+ VIEW v1 AS SELECT a FROM t1;
+
+CREATE
DEFINER=some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY
+ VIEW v2 AS SELECT b FROM t1;
+
+# Test.
+
+SHOW CREATE VIEW v1;
+SHOW CREATE VIEW v2;
+
+# Cleanup.
+
+DROP TABLE t1;
+DROP VIEW v1;
+DROP VIEW v2;
--- 1.41/mysql-test/r/trigger.result 2006-06-16 20:21:21 +04:00
+++ 1.42/mysql-test/r/trigger.result 2006-06-28 18:05:32 +04:00
@@ -1078,3 +1078,23 @@ i1
43
51
DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+CREATE TABLE t1(c INT);
+CREATE TABLE t2(c INT);
+CREATE DEFINER=1234567890abcdefGHIKL@localhost
+TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW SET @a = 1;
+Warnings:
+Note 1465 The user name has been truncated to 16 symbols
+Note 1449 There is no '1234567890abcdef'@'localhost' registered
+CREATE
DEFINER=some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY
+TRIGGER t2_bi BEFORE INSERT ON t2 FOR EACH ROW SET @a = 2;
+Warnings:
+Note 1466 The host name has been truncated to 60 symbols
+Note 1449 There is no
'some_user_name'@'1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij'
registered
+INSERT INTO t1 VALUES(1);
+ERROR HY000: There is no '1234567890abcdef'@'localhost' registered
+INSERT INTO t2 VALUES(2);
+ERROR HY000: There is no
'some_user_name'@'1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij'
registered
+DROP TABLE t1;
+DROP TABLE t2;
--- 1.46/mysql-test/t/trigger.test 2006-06-16 20:21:21 +04:00
+++ 1.47/mysql-test/t/trigger.test 2006-06-28 18:05:32 +04:00
@@ -1281,4 +1281,39 @@ SELECT * FROM t1;
DROP TABLE t1;
+
+#
+# Test for BUG#16899: Possible buffer overflow in handling of DEFINER-clause.
+#
+
+# Prepare.
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+--enable_warnings
+
+CREATE TABLE t1(c INT);
+CREATE TABLE t2(c INT);
+
+CREATE DEFINER=1234567890abcdefGHIKL@localhost
+ TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW SET @a = 1;
+
+CREATE
DEFINER=some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY
+ TRIGGER t2_bi BEFORE INSERT ON t2 FOR EACH ROW SET @a = 2;
+
+# Test.
+
+--error ER_NO_SUCH_USER
+INSERT INTO t1 VALUES(1);
+
+--error ER_NO_SUCH_USER
+INSERT INTO t2 VALUES(2);
+
+# Cleanup.
+
+DROP TABLE t1;
+DROP TABLE t2;
+
+
# End of 5.0 tests
--- 1.51/sql/sql_trigger.cc 2006-06-28 03:11:09 +04:00
+++ 1.52/sql/sql_trigger.cc 2006-06-28 18:05:33 +04:00
@@ -978,7 +978,7 @@ bool Table_triggers_list::check_n_load(T
schema.
*/
- lex.sphead->set_definer("", 0);
+ lex.sphead->set_definer(thd, "", 0);
/*
Triggers without definer information are executed under the
@@ -988,7 +988,7 @@ bool Table_triggers_list::check_n_load(T
lex.sphead->m_chistics->suid= SP_IS_NOT_SUID;
}
else
- lex.sphead->set_definer(trg_definer->str, trg_definer->length);
+ lex.sphead->set_definer(thd, trg_definer->str, trg_definer->length);
if (triggers->names_list.push_back(&lex.sphead->m_name,
&table->mem_root))
--- 1.202/mysql-test/r/sp.result 2006-06-27 00:52:52 +04:00
+++ 1.203/mysql-test/r/sp.result 2006-06-28 18:05:32 +04:00
@@ -5057,4 +5057,27 @@ concat('data was: /', var1, '/')
data was: /1/
drop table t3|
drop procedure bug15217|
+DROP PROCEDURE IF EXISTS bug16899_p1|
+DROP FUNCTION IF EXISTS bug16899_f1|
+CREATE DEFINER=1234567890abcdefGHIKL@localhost PROCEDURE bug16899_p1()
+BEGIN
+SET @a = 1;
+END|
+Warnings:
+Note 1465 The user name has been truncated to 16 symbols
+Note 1449 There is no '1234567890abcdef'@'localhost' registered
+CREATE
DEFINER=some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY
+FUNCTION bug16899_f1() RETURNS INT
+BEGIN
+RETURN 1;
+END|
+Warnings:
+Note 1466 The host name has been truncated to 60 symbols
+Note 1449 There is no
'some_user_name'@'1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij'
registered
+CALL bug16899_p1()|
+ERROR HY000: There is no '1234567890abcdef'@'localhost' registered
+SELECT bug16899_f1()|
+ERROR HY000: There is no
'some_user_name'@'1234567890abcdefghij1234567890abcdefghij1234567890abcdefghij'
registered
+DROP PROCEDURE bug16899_p1|
+DROP FUNCTION bug16899_f1|
drop table t1,t2;
--- 1.190/mysql-test/t/sp.test 2006-06-27 00:52:52 +04:00
+++ 1.191/mysql-test/t/sp.test 2006-06-28 18:05:32 +04:00
@@ -5963,6 +5963,42 @@ drop table t3|
drop procedure bug15217|
#
+# Test for BUG#16899: Possible buffer overflow in handling of DEFINER-clause.
+#
+
+# Prepare.
+
+--disable_warnings
+DROP PROCEDURE IF EXISTS bug16899_p1|
+DROP FUNCTION IF EXISTS bug16899_f1|
+--enable_warnings
+
+CREATE DEFINER=1234567890abcdefGHIKL@localhost PROCEDURE bug16899_p1()
+BEGIN
+ SET @a = 1;
+END|
+
+CREATE
DEFINER=some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY
+ FUNCTION bug16899_f1() RETURNS INT
+BEGIN
+ RETURN 1;
+END|
+
+# Test.
+
+--error ER_NO_SUCH_USER
+CALL bug16899_p1()|
+
+--error ER_NO_SUCH_USER
+SELECT bug16899_f1()|
+
+# Cleanup.
+
+DROP PROCEDURE bug16899_p1|
+DROP FUNCTION bug16899_f1|
+
+
+#
# BUG#NNNN: New bug synopsis
#
#--disable_warnings
--- 1.114/sql/sp.cc 2006-06-28 03:11:09 +04:00
+++ 1.115/sql/sp.cc 2006-06-28 18:05:32 +04:00
@@ -410,7 +410,7 @@ db_load_routine(THD *thd, int type, sp_n
ulong old_sql_mode= thd->variables.sql_mode;
ha_rows old_select_limit= thd->variables.select_limit;
sp_rcontext *old_spcont= thd->spcont;
-
+
char definer_user_name_holder[USERNAME_LENGTH + 1];
LEX_STRING_WITH_INIT definer_user_name(definer_user_name_holder,
USERNAME_LENGTH);
@@ -418,7 +418,10 @@ db_load_routine(THD *thd, int type, sp_n
char definer_host_name_holder[HOSTNAME_LENGTH + 1];
LEX_STRING_WITH_INIT definer_host_name(definer_host_name_holder,
HOSTNAME_LENGTH);
-
+
+ bool definer_user_name_truncated;
+ bool definer_host_name_truncated;
+
int ret;
thd->variables.sql_mode= sql_mode;
@@ -427,9 +430,34 @@ db_load_routine(THD *thd, int type, sp_n
thd->lex= &newlex;
newlex.current_select= NULL;
+ /*
+ Split the definer into user and host names.
+
+ If user name (host name) is longer than USERNAME_LENGTH (HOSTNAME_LENGTH),
+ it will be truncated and corresponding warning will be emitted. This
+ truncation can occur, when we are loading stored routine created in the
+ MySQL before 5.0.23 -- there was no checkings for length. As of 5.0.23
+ such checkings are before creating the stored routine, so we will never
+ truncate here.
+ */
+
parse_user(definer, strlen(definer),
definer_user_name.str, &definer_user_name.length,
- definer_host_name.str, &definer_host_name.length);
+ definer_host_name.str, &definer_host_name.length,
+ &definer_user_name_truncated,
+ &definer_host_name_truncated);
+
+ if (definer_user_name_truncated)
+ push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
+ ER_USER_NAME_TRUNCATED,
+ ER(ER_USER_NAME_TRUNCATED),
+ USERNAME_LENGTH);
+
+ if (definer_host_name_truncated)
+ push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
+ ER_HOST_NAME_TRUNCATED,
+ ER(ER_HOST_NAME_TRUNCATED),
+ HOSTNAME_LENGTH);
defstr.set_charset(system_charset_info);
--- 1.217/sql/sp_head.cc 2006-06-27 00:50:50 +04:00
+++ 1.218/sql/sp_head.cc 2006-06-28 18:05:32 +04:00
@@ -1753,7 +1753,7 @@ sp_head::set_info(longlong created, long
void
-sp_head::set_definer(const char *definer, uint definerlen)
+sp_head::set_definer(THD *thd, const char *definer, uint definerlen)
{
char user_name_holder[USERNAME_LENGTH + 1];
LEX_STRING_WITH_INIT user_name(user_name_holder, USERNAME_LENGTH);
@@ -1761,8 +1761,37 @@ sp_head::set_definer(const char *definer
char host_name_holder[HOSTNAME_LENGTH + 1];
LEX_STRING_WITH_INIT host_name(host_name_holder, HOSTNAME_LENGTH);
- parse_user(definer, definerlen, user_name.str, &user_name.length,
- host_name.str, &host_name.length);
+ bool definer_user_name_truncated;
+ bool definer_host_name_truncated;
+
+ /*
+ Split the definer into user and host names.
+
+ If user name (host name) is longer than USERNAME_LENGTH (HOSTNAME_LENGTH),
+ it will be truncated and corresponding warning will be emitted. This
+ truncation can occur, when we are loading stored routine or trigger
+ created in the MySQL before 5.0.23 -- there was no checkings for length.
+ As of 5.0.23 such checkings are before creating the stored routine, so we
+ will never truncate here.
+ */
+
+ parse_user(definer, definerlen,
+ user_name.str, &user_name.length,
+ host_name.str, &host_name.length,
+ &definer_user_name_truncated,
+ &definer_host_name_truncated);
+
+ if (definer_user_name_truncated)
+ push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
+ ER_USER_NAME_TRUNCATED,
+ ER(ER_USER_NAME_TRUNCATED),
+ USERNAME_LENGTH);
+
+ if (definer_host_name_truncated)
+ push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
+ ER_HOST_NAME_TRUNCATED,
+ ER(ER_HOST_NAME_TRUNCATED),
+ HOSTNAME_LENGTH);
set_definer(&user_name, &host_name);
}
--- 1.85/sql/sp_head.h 2006-06-27 00:47:47 +04:00
+++ 1.86/sql/sp_head.h 2006-06-28 18:05:33 +04:00
@@ -285,7 +285,7 @@ public:
void set_info(longlong created, longlong modified,
st_sp_chistics *chistics, ulong sql_mode);
- void set_definer(const char *definer, uint definerlen);
+ void set_definer(THD *thd, const char *definer, uint definerlen);
void set_definer(const LEX_STRING *user_name, const LEX_STRING *host_name);
void reset_thd_mem_root(THD *thd);
| Thread |
|---|
| • bk commit into 5.0 tree (anozdrin:1.2204) BUG#16899 | Alexander Nozdrin | 28 Jun |