summaryrefslogtreecommitdiff
path: root/sql/sql_parse.cc
diff options
context:
space:
mode:
authorunknown <davi@endora.local>2007-11-01 17:29:20 -0200
committerunknown <davi@endora.local>2007-11-01 17:29:20 -0200
commit8f0df2efe85ae6d241ed045a4100d207ddb4ed1c (patch)
treee2439b0b42b30ea2e2147c6621485bbd2149cdb1 /sql/sql_parse.cc
parent17d2230550a34d3cd99d3eb34e9f4e07ca1872d8 (diff)
downloadmariadb-git-8f0df2efe85ae6d241ed045a4100d207ddb4ed1c.tar.gz
Bug#31850 Test crashes in "embedded" server
The mysql_change_user command fails to properly update the database pointer when no database is selected, leading to "use after free" errors. The same happens on the user privilege pointer in the thread security context. The solution is to properly reset and update the database name. Also update the user_priv pointer so that it doesn't point to freed memory. sql/sql_connect.cc: After a successful call to check_user() without specifying a new database name, the previous database thd->db) is freed but the pointer is not updated to NULL. sql/sql_parse.cc: Update the security_ctx->priv_user pointer as it is a alias for the user security_ctx->user pointer. Also remove unneeded cast, the x_free macro casts the argument.
Diffstat (limited to 'sql/sql_parse.cc')
-rw-r--r--sql/sql_parse.cc5
1 files changed, 3 insertions, 2 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 85457fea41b..b2f2e74999b 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -911,6 +911,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
/* Clear variables that are allocated */
thd->user_connect= 0;
+ thd->security_ctx->priv_user= thd->security_ctx->user;
res= check_user(thd, COM_CHANGE_USER, passwd, passwd_len, db, FALSE);
if (res)
@@ -933,8 +934,8 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
if (save_user_connect)
decrease_user_connections(save_user_connect);
#endif /* NO_EMBEDDED_ACCESS_CHECKS */
- x_free((uchar*) save_db);
- x_free((uchar*) save_security_ctx.user);
+ x_free(save_db);
+ x_free(save_security_ctx.user);
if (cs_number)
{