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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
df53ed13
Commit
df53ed13
authored
Oct 17, 2013
by
Vicențiu Ciorbaru
Committed by
Sergei Golubchik
Oct 17, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Renamed variables in init_role_grant_pair to make the code more
consistent.
parent
2f94e542
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
15 deletions
+15
-15
sql/sql_acl.cc
sql/sql_acl.cc
+15
-15
No files found.
sql/sql_acl.cc
View file @
df53ed13
...
...
@@ -552,35 +552,35 @@ static uchar* acl_role_map_get_key(ROLE_GRANT_PAIR *entry, size_t *length,
static
void
init_role_grant_pair
(
MEM_ROOT
*
mem
,
ROLE_GRANT_PAIR
*
entry
,
char
*
username
,
char
*
hostname
,
char
*
rolename
)
{
size_t
len
[
3
]
=
{
username
?
strlen
(
username
)
:
0
,
hostname
?
strlen
(
hostname
)
:
0
,
rolename
?
strlen
(
rolename
)
:
0
}
;
size_t
uname_l
=
username
?
strlen
(
username
)
:
0
;
size_t
hname_l
=
hostname
?
strlen
(
hostname
)
:
0
;
size_t
rname_l
=
rolename
?
strlen
(
rolename
)
:
0
;
/*
Create a buffer that holds all 3 NULL terminated strings in succession
To save memory space, the same buffer is used as the hashkey
*/
size_t
bufflen
=
len
[
0
]
+
len
[
1
]
+
len
[
2
]
+
3
;
//add the '\0' aswell
size_t
bufflen
=
uname_l
+
hname_l
+
rname_l
+
3
;
//add the '\0' aswell
char
*
buff
=
(
char
*
)
alloc_root
(
mem
,
bufflen
);
/*
Offsets in the buffer for all 3 strings
*/
char
*
username_pos
=
buff
;
char
*
hostname_pos
=
buff
+
len
[
0
]
+
1
;
char
*
rolename_pos
=
buff
+
len
[
0
]
+
len
[
1
]
+
2
;
char
*
hostname_pos
=
buff
+
uname_l
+
1
;
char
*
rolename_pos
=
buff
+
uname_l
+
hname_l
+
2
;
if
(
username
)
memcpy
(
username_pos
,
username
,
len
[
0
]
);
username_pos
[
len
[
0
]
]
=
'\0'
;
//#1 string terminator
if
(
username
)
//prevent undefined behaviour
memcpy
(
username_pos
,
username
,
uname_l
);
username_pos
[
uname_l
]
=
'\0'
;
//#1 string terminator
entry
->
u_uname
=
username_pos
;
if
(
hostname
)
memcpy
(
hostname_pos
,
hostname
,
len
[
1
]
);
hostname_pos
[
len
[
1
]
]
=
'\0'
;
//#2 string terminator
if
(
hostname
)
//prevent undefined behaviour
memcpy
(
hostname_pos
,
hostname
,
hname_l
);
hostname_pos
[
hname_l
]
=
'\0'
;
//#2 string terminator
entry
->
u_hname
=
hostname_pos
;
if
(
rolename
)
memcpy
(
rolename_pos
,
rolename
,
len
[
2
]
);
rolename_pos
[
len
[
2
]
]
=
'\0'
;
//#3 string terminator
if
(
rolename
)
//prevent undefined behaviour
memcpy
(
rolename_pos
,
rolename
,
rname_l
);
rolename_pos
[
rname_l
]
=
'\0'
;
//#3 string terminator
entry
->
r_uname
=
rolename_pos
;
entry
->
hashkey
.
str
=
buff
;
...
...
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