MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:msvensson Date:April 18 2006 8:46am
Subject:bk commit into 5.0 tree (msvensson:1.2087) BUG#13310
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of msvensson. When msvensson 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.2087 06/04/18 10:46:17 msvensson@shellback.(none) +3 -0
  BUG#13310 incorrect user parsing by SP
   - Strip surrounding ''s from username when a new user connects. There
     is no user 'a@', it should be a@

  sql/sql_parse.cc
    1.536 06/04/18 10:46:11 msvensson@shellback.(none) +12 -3
    Strip surrounding ''s from username when a new user connects. There 
    is no user 'a@', it should be a@

  mysql-test/t/grant2.test
    1.33 06/04/18 10:46:11 msvensson@shellback.(none) +25 -0
    Add tests for bug 13310

  mysql-test/r/grant2.result
    1.27 06/04/18 10:46:11 msvensson@shellback.(none) +13 -0
    Update test result

# 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:	msvensson
# Host:	shellback.(none)
# Root:	/home/msvensson/mysql/bug13310/my50-bug13310

--- 1.535/sql/sql_parse.cc	2006-03-10 12:40:12 +01:00
+++ 1.536/sql/sql_parse.cc	2006-04-18 10:46:11 +02:00
@@ -993,6 +993,7 @@
 
   char *user= end;
   char *passwd= strend(user)+1;
+  uint user_len= passwd - user - 1;
   char *db= passwd;
   char db_buff[NAME_LEN+1];                     // buffer to store db in utf8
   char user_buff[USERNAME_LENGTH+1];		// buffer to store user in utf8
@@ -1018,10 +1019,18 @@
     db= db_buff;
   }
 
-  user_buff[copy_and_convert(user_buff, sizeof(user_buff)-1,
-                             system_charset_info, user, strlen(user),
-                             thd->charset(), &dummy_errors)]= '\0';
+  user_buff[user_len= copy_and_convert(user_buff, sizeof(user_buff)-1,
+                                       system_charset_info, user, user_len,
+                                       thd->charset(), &dummy_errors)]= '\0';
   user= user_buff;
+
+  /* If username starts and ends in "'", chop them off */
+  if (user_len > 1 && user[0] == '\'' && user[user_len - 1] == '\'')
+  {
+    user[user_len-1]= 0;
+    user++;
+    user_len-= 2;
+  }
 
   if (thd->main_security_ctx.user)
     x_free(thd->main_security_ctx.user);

--- 1.26/mysql-test/r/grant2.result	2006-03-02 11:01:54 +01:00
+++ 1.27/mysql-test/r/grant2.result	2006-04-18 10:46:11 +02:00
@@ -356,3 +356,16 @@
 drop table t1, t2;
 drop database TESTDB;
 flush privileges;
+grant all privileges on test.* to `a@`@localhost;
+grant execute on * to `a@`@localhost;
+create table t2 (s1 int);
+insert into t2 values (1);
+drop function if exists f2;
+create function f2 () returns int begin declare v int; select s1 from t2
+into v; return v; end//
+select f2();
+f2()
+1
+drop function f2;
+drop table t2;
+REVOKE ALL PRIVILEGES, GRANT OPTION FROM `a@`@localhost;

--- 1.32/mysql-test/t/grant2.test	2006-03-02 11:01:54 +01:00
+++ 1.33/mysql-test/t/grant2.test	2006-04-18 10:46:11 +02:00
@@ -465,3 +465,28 @@
 drop database TESTDB;
 flush privileges;
 
+#
+# BUG#13310 incorrect user parsing by SP
+#
+
+grant all privileges on test.* to `a@`@localhost;
+grant execute on * to `a@`@localhost;
+connect (bug13310,localhost,'a@',,test);
+connection bug13310;
+create table t2 (s1 int);
+insert into t2 values (1);
+--disable_warnings
+drop function if exists f2;
+--enable_warnings
+delimiter //;
+create function f2 () returns int begin declare v int; select s1 from t2
+into v; return v; end//
+delimiter ;//
+select f2();
+
+drop function f2;
+drop table t2;
+disconnect bug13310;
+
+connection default;
+REVOKE ALL PRIVILEGES, GRANT OPTION FROM `a@`@localhost;
Thread
bk commit into 5.0 tree (msvensson:1.2087) BUG#13310msvensson18 Apr