Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
ca7401af
Commit
ca7401af
authored
Oct 12, 2018
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup: safe_lexcstrdup_root()
parent
dfbba3d2
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
34 deletions
+26
-34
include/my_sys.h
include/my_sys.h
+1
-0
mysys/my_alloc.c
mysys/my_alloc.c
+11
-0
sql/sql_acl.cc
sql/sql_acl.cc
+12
-22
sql/sql_trigger.cc
sql/sql_trigger.cc
+2
-12
No files found.
include/my_sys.h
View file @
ca7401af
...
@@ -903,6 +903,7 @@ static inline char *safe_strdup_root(MEM_ROOT *root, const char *str)
...
@@ -903,6 +903,7 @@ static inline char *safe_strdup_root(MEM_ROOT *root, const char *str)
}
}
extern
char
*
strmake_root
(
MEM_ROOT
*
root
,
const
char
*
str
,
size_t
len
);
extern
char
*
strmake_root
(
MEM_ROOT
*
root
,
const
char
*
str
,
size_t
len
);
extern
void
*
memdup_root
(
MEM_ROOT
*
root
,
const
void
*
str
,
size_t
len
);
extern
void
*
memdup_root
(
MEM_ROOT
*
root
,
const
void
*
str
,
size_t
len
);
extern
LEX_CSTRING
safe_lexcstrdup_root
(
MEM_ROOT
*
root
,
const
LEX_CSTRING
str
);
extern
my_bool
my_compress
(
uchar
*
,
size_t
*
,
size_t
*
);
extern
my_bool
my_compress
(
uchar
*
,
size_t
*
,
size_t
*
);
extern
my_bool
my_uncompress
(
uchar
*
,
size_t
,
size_t
*
);
extern
my_bool
my_uncompress
(
uchar
*
,
size_t
,
size_t
*
);
extern
uchar
*
my_compress_alloc
(
const
uchar
*
packet
,
size_t
*
len
,
extern
uchar
*
my_compress_alloc
(
const
uchar
*
packet
,
size_t
*
len
,
...
...
mysys/my_alloc.c
View file @
ca7401af
...
@@ -492,3 +492,14 @@ void *memdup_root(MEM_ROOT *root, const void *str, size_t len)
...
@@ -492,3 +492,14 @@ void *memdup_root(MEM_ROOT *root, const void *str, size_t len)
memcpy
(
pos
,
str
,
len
);
memcpy
(
pos
,
str
,
len
);
return
pos
;
return
pos
;
}
}
LEX_CSTRING
safe_lexcstrdup_root
(
MEM_ROOT
*
root
,
const
LEX_CSTRING
str
)
{
LEX_CSTRING
res
;
if
(
str
.
length
)
res
.
str
=
strmake_root
(
root
,
str
.
str
,
str
.
length
);
else
res
.
str
=
(
const
char
*
)
""
;
res
.
length
=
str
.
length
;
return
res
;
}
sql/sql_acl.cc
View file @
ca7401af
...
@@ -152,8 +152,7 @@ class ACL_USER :public ACL_USER_BASE
...
@@ -152,8 +152,7 @@ class ACL_USER :public ACL_USER_BASE
if
(
!
dst
)
if
(
!
dst
)
return
0
;
return
0
;
*
dst
=
*
this
;
*
dst
=
*
this
;
dst
->
user
.
str
=
safe_strdup_root
(
root
,
user
.
str
);
dst
->
user
=
safe_lexcstrdup_root
(
root
,
user
);
dst
->
user
.
length
=
user
.
length
;
dst
->
ssl_cipher
=
safe_strdup_root
(
root
,
ssl_cipher
);
dst
->
ssl_cipher
=
safe_strdup_root
(
root
,
ssl_cipher
);
dst
->
x509_issuer
=
safe_strdup_root
(
root
,
x509_issuer
);
dst
->
x509_issuer
=
safe_strdup_root
(
root
,
x509_issuer
);
dst
->
x509_subject
=
safe_strdup_root
(
root
,
x509_subject
);
dst
->
x509_subject
=
safe_strdup_root
(
root
,
x509_subject
);
...
@@ -161,11 +160,10 @@ class ACL_USER :public ACL_USER_BASE
...
@@ -161,11 +160,10 @@ class ACL_USER :public ACL_USER_BASE
plugin
.
str
==
old_password_plugin_name
.
str
)
plugin
.
str
==
old_password_plugin_name
.
str
)
dst
->
plugin
=
plugin
;
dst
->
plugin
=
plugin
;
else
else
dst
->
plugin
.
str
=
strmake_root
(
root
,
plugin
.
str
,
plugin
.
length
);
dst
->
plugin
=
safe_lexcstrdup_root
(
root
,
plugin
);
dst
->
auth_string
.
str
=
safe_strdup_root
(
root
,
auth_string
.
str
);
dst
->
auth_string
=
safe_lexcstrdup_root
(
root
,
auth_string
);
dst
->
host
.
hostname
=
safe_strdup_root
(
root
,
host
.
hostname
);
dst
->
host
.
hostname
=
safe_strdup_root
(
root
,
host
.
hostname
);
dst
->
default_rolename
.
str
=
safe_strdup_root
(
root
,
default_rolename
.
str
);
dst
->
default_rolename
=
safe_lexcstrdup_root
(
root
,
default_rolename
);
dst
->
default_rolename
.
length
=
default_rolename
.
length
;
bzero
(
&
dst
->
role_grants
,
sizeof
(
role_grants
));
bzero
(
&
dst
->
role_grants
,
sizeof
(
role_grants
));
return
dst
;
return
dst
;
}
}
...
@@ -1337,8 +1335,7 @@ ACL_ROLE::ACL_ROLE(ACL_USER *user, MEM_ROOT *root) : counter(0)
...
@@ -1337,8 +1335,7 @@ ACL_ROLE::ACL_ROLE(ACL_USER *user, MEM_ROOT *root) : counter(0)
access
=
user
->
access
;
access
=
user
->
access
;
/* set initial role access the same as the table row privileges */
/* set initial role access the same as the table row privileges */
initial_role_access
=
user
->
access
;
initial_role_access
=
user
->
access
;
this
->
user
.
str
=
safe_strdup_root
(
root
,
user
->
user
.
str
);
this
->
user
=
safe_lexcstrdup_root
(
root
,
user
->
user
);
this
->
user
.
length
=
user
->
user
.
length
;
bzero
(
&
role_grants
,
sizeof
(
role_grants
));
bzero
(
&
role_grants
,
sizeof
(
role_grants
));
bzero
(
&
parent_grantee
,
sizeof
(
parent_grantee
));
bzero
(
&
parent_grantee
,
sizeof
(
parent_grantee
));
flags
=
IS_ROLE
;
flags
=
IS_ROLE
;
...
@@ -2628,11 +2625,9 @@ static void acl_update_user(const char *user, const char *host,
...
@@ -2628,11 +2625,9 @@ static void acl_update_user(const char *user, const char *host,
if
(
plugin
->
str
[
0
])
if
(
plugin
->
str
[
0
])
{
{
acl_user
->
plugin
=
*
plugin
;
acl_user
->
plugin
=
*
plugin
;
acl_user
->
auth_string
.
str
=
auth
->
str
?
acl_user
->
auth_string
=
safe_lexcstrdup_root
(
&
acl_memroot
,
*
auth
);
strmake_root
(
&
acl_memroot
,
auth
->
str
,
auth
->
length
)
:
const_cast
<
char
*>
(
""
);
acl_user
->
auth_string
.
length
=
auth
->
length
;
if
(
fix_user_plugin_ptr
(
acl_user
))
if
(
fix_user_plugin_ptr
(
acl_user
))
acl_user
->
plugin
.
str
=
strmake_root
(
&
acl_memroot
,
plugin
->
str
,
plugin
->
length
);
acl_user
->
plugin
=
safe_lexcstrdup_root
(
&
acl_memroot
,
*
plugin
);
}
}
else
else
if
(
password
[
0
])
if
(
password
[
0
])
...
@@ -2707,11 +2702,9 @@ static void acl_insert_user(const char *user, const char *host,
...
@@ -2707,11 +2702,9 @@ static void acl_insert_user(const char *user, const char *host,
if
(
plugin
->
str
[
0
])
if
(
plugin
->
str
[
0
])
{
{
acl_user
.
plugin
=
*
plugin
;
acl_user
.
plugin
=
*
plugin
;
acl_user
.
auth_string
.
str
=
auth
->
str
?
acl_user
.
auth_string
=
safe_lexcstrdup_root
(
&
acl_memroot
,
*
auth
);
strmake_root
(
&
acl_memroot
,
auth
->
str
,
auth
->
length
)
:
const_cast
<
char
*>
(
""
);
acl_user
.
auth_string
.
length
=
auth
->
length
;
if
(
fix_user_plugin_ptr
(
&
acl_user
))
if
(
fix_user_plugin_ptr
(
&
acl_user
))
acl_user
.
plugin
.
str
=
strmake_root
(
&
acl_memroot
,
plugin
->
str
,
plugin
->
length
);
acl_user
.
plugin
=
safe_lexcstrdup_root
(
&
acl_memroot
,
*
plugin
);
}
}
else
else
{
{
...
@@ -3299,8 +3292,7 @@ bool change_password(THD *thd, LEX_USER *user)
...
@@ -3299,8 +3292,7 @@ bool change_password(THD *thd, LEX_USER *user)
if
(
acl_user
->
plugin
.
str
==
native_password_plugin_name
.
str
||
if
(
acl_user
->
plugin
.
str
==
native_password_plugin_name
.
str
||
acl_user
->
plugin
.
str
==
old_password_plugin_name
.
str
)
acl_user
->
plugin
.
str
==
old_password_plugin_name
.
str
)
{
{
acl_user
->
auth_string
.
str
=
strmake_root
(
&
acl_memroot
,
user
->
pwhash
.
str
,
user
->
pwhash
.
length
);
acl_user
->
auth_string
=
safe_lexcstrdup_root
(
&
acl_memroot
,
user
->
pwhash
);
acl_user
->
auth_string
.
length
=
user
->
pwhash
.
length
;
set_user_salt
(
acl_user
,
user
->
pwhash
.
str
,
user
->
pwhash
.
length
);
set_user_salt
(
acl_user
,
user
->
pwhash
.
str
,
user
->
pwhash
.
length
);
set_user_plugin
(
acl_user
,
user
->
pwhash
.
length
);
set_user_plugin
(
acl_user
,
user
->
pwhash
.
length
);
...
@@ -9608,8 +9600,7 @@ static int handle_grant_struct(enum enum_acl_lists struct_no, bool drop,
...
@@ -9608,8 +9600,7 @@ static int handle_grant_struct(enum enum_acl_lists struct_no, bool drop,
my_hash_delete
(
&
acl_roles
,
(
uchar
*
)
acl_role
);
my_hash_delete
(
&
acl_roles
,
(
uchar
*
)
acl_role
);
DBUG_RETURN
(
1
);
DBUG_RETURN
(
1
);
}
}
acl_role
->
user
.
str
=
strdup_root
(
&
acl_memroot
,
user_to
->
user
.
str
);
acl_role
->
user
=
safe_lexcstrdup_root
(
&
acl_memroot
,
user_to
->
user
);
acl_role
->
user
.
length
=
user_to
->
user
.
length
;
my_hash_update
(
&
acl_roles
,
(
uchar
*
)
acl_role
,
(
uchar
*
)
old_key
,
my_hash_update
(
&
acl_roles
,
(
uchar
*
)
acl_role
,
(
uchar
*
)
old_key
,
old_key_length
);
old_key_length
);
...
@@ -9800,8 +9791,7 @@ static int handle_grant_struct(enum enum_acl_lists struct_no, bool drop,
...
@@ -9800,8 +9791,7 @@ static int handle_grant_struct(enum enum_acl_lists struct_no, bool drop,
{
{
switch
(
struct_no
)
{
switch
(
struct_no
)
{
case
USER_ACL
:
case
USER_ACL
:
acl_user
->
user
.
str
=
strdup_root
(
&
acl_memroot
,
user_to
->
user
.
str
);
acl_user
->
user
=
safe_lexcstrdup_root
(
&
acl_memroot
,
user_to
->
user
);
acl_user
->
user
.
length
=
user_to
->
user
.
length
;
update_hostname
(
&
acl_user
->
host
,
strdup_root
(
&
acl_memroot
,
user_to
->
host
.
str
));
update_hostname
(
&
acl_user
->
host
,
strdup_root
(
&
acl_memroot
,
user_to
->
host
.
str
));
acl_user
->
hostname_length
=
strlen
(
acl_user
->
host
.
hostname
);
acl_user
->
hostname_length
=
strlen
(
acl_user
->
host
.
hostname
);
break
;
break
;
...
...
sql/sql_trigger.cc
View file @
ca7401af
...
@@ -35,16 +35,6 @@
...
@@ -35,16 +35,6 @@
#include "sp_cache.h" // sp_invalidate_cache
#include "sp_cache.h" // sp_invalidate_cache
#include <mysys_err.h>
#include <mysys_err.h>
LEX_CSTRING
*
make_lex_string
(
LEX_CSTRING
*
lex_str
,
const
char
*
str
,
size_t
length
,
MEM_ROOT
*
mem_root
)
{
if
(
!
(
lex_str
->
str
=
strmake_root
(
mem_root
,
str
,
length
)))
return
0
;
lex_str
->
length
=
length
;
return
lex_str
;
}
/*************************************************************************/
/*************************************************************************/
/**
/**
...
@@ -1503,8 +1493,8 @@ bool Table_triggers_list::check_n_load(THD *thd, const LEX_CSTRING *db,
...
@@ -1503,8 +1493,8 @@ bool Table_triggers_list::check_n_load(THD *thd, const LEX_CSTRING *db,
if
(
likely
((
name
=
error_handler
.
get_trigger_name
())))
if
(
likely
((
name
=
error_handler
.
get_trigger_name
())))
{
{
if
(
unlikely
(
!
(
make_lex_string
(
&
trigger
->
name
,
name
->
str
,
trigger
->
name
=
safe_lexcstrdup_root
(
&
table
->
mem_root
,
*
name
);
name
->
length
,
&
table
->
mem_root
))
))
if
(
unlikely
(
!
trigger
->
name
.
str
))
goto
err_with_lex_cleanup
;
goto
err_with_lex_cleanup
;
}
}
trigger
->
definer
=
((
!
trg_definer
||
!
trg_definer
->
length
)
?
trigger
->
definer
=
((
!
trg_definer
||
!
trg_definer
->
length
)
?
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment