mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
fixes for valgrind failures
sql/item.cc: don't forget to adjust the length of the string when removing leading spaces sql/sql_acl.cc: when updating the hostname of the ACL_USER, update the hostname_length too sql/sql_parse.cc: first compare the username string, then test the host pointer (host pointer is undefined when the username string is one of the hard-coded values set by the parser). This is not a bug, old code is perfectly safe as the undefined host pointer is never dereferenced, but let's keep valgrind happy.
This commit is contained in:
@ -1078,6 +1078,7 @@ void Item::set_name(const char *str, uint length, CHARSET_INFO *cs)
|
|||||||
if (!cs->ctype || cs->mbminlen > 1)
|
if (!cs->ctype || cs->mbminlen > 1)
|
||||||
{
|
{
|
||||||
str+= cs->cset->scan(cs, str, str + length, MY_SEQ_SPACES);
|
str+= cs->cset->scan(cs, str, str + length, MY_SEQ_SPACES);
|
||||||
|
length-= str - str_start;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -8868,6 +8868,7 @@ static int handle_grant_struct(enum enum_acl_lists struct_no, bool drop,
|
|||||||
acl_user->user.str= strdup_root(&acl_memroot, user_to->user.str);
|
acl_user->user.str= strdup_root(&acl_memroot, user_to->user.str);
|
||||||
acl_user->user.length= user_to->user.length;
|
acl_user->user.length= user_to->user.length;
|
||||||
acl_user->host.hostname= strdup_root(&acl_memroot, user_to->host.str);
|
acl_user->host.hostname= strdup_root(&acl_memroot, user_to->host.str);
|
||||||
|
acl_user->hostname_length= user_to->host.length;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DB_ACL:
|
case DB_ACL:
|
||||||
|
@ -4335,12 +4335,12 @@ end_with_restore_list:
|
|||||||
case SQLCOM_SHOW_GRANTS:
|
case SQLCOM_SHOW_GRANTS:
|
||||||
{
|
{
|
||||||
LEX_USER *grant_user= lex->grant_user;
|
LEX_USER *grant_user= lex->grant_user;
|
||||||
|
Security_context *sctx= thd->security_ctx;
|
||||||
if (!grant_user)
|
if (!grant_user)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (grant_user->user.str && grant_user->host.str &&
|
if (grant_user->user.str && !strcmp(sctx->priv_user, grant_user->user.str) &&
|
||||||
!strcmp(thd->security_ctx->priv_user, grant_user->user.str) &&
|
grant_user->host.str && !strcmp(sctx->priv_host, grant_user->host.str))
|
||||||
!strcmp(thd->security_ctx->priv_host, grant_user->host.str))
|
|
||||||
grant_user->user= current_user;
|
grant_user->user= current_user;
|
||||||
|
|
||||||
if (grant_user->user.str == current_user.str ||
|
if (grant_user->user.str == current_user.str ||
|
||||||
|
Reference in New Issue
Block a user