Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
af72a314
You need to sign in or sign up before continuing.
Commit
af72a314
authored
Jan 26, 2019
by
antirez
Browse files
ACL: fix command bit check.
parent
b7750a93
Changes
1
Show whitespace changes
Inline
Side-by-side
src/acl.c
View file @
af72a314
...
@@ -160,10 +160,10 @@ user *ACLCreateUser(const char *name, size_t namelen) {
...
@@ -160,10 +160,10 @@ user *ACLCreateUser(const char *name, size_t namelen) {
* so that user->allowed_commands[word]&bit will identify that specific
* so that user->allowed_commands[word]&bit will identify that specific
* bit. The function returns C_ERR in case the specified ID overflows
* bit. The function returns C_ERR in case the specified ID overflows
* the bitmap in the user representation. */
* the bitmap in the user representation. */
int
ACLGetCommandBitCoordinates
(
u
nsigned
long
id
,
uint64_t
*
word
,
uint64_t
*
bit
)
{
int
ACLGetCommandBitCoordinates
(
u
int64_t
id
,
uint64_t
*
word
,
uint64_t
*
bit
)
{
if
(
id
>=
USER_COMMAND_BITS_COUNT
)
return
C_ERR
;
if
(
id
>=
USER_COMMAND_BITS_COUNT
)
return
C_ERR
;
*
word
=
id
/
sizeof
(
uint64_t
)
/
8
;
*
word
=
id
/
sizeof
(
uint64_t
)
/
8
;
*
bit
=
1
<<
(
id
%
(
sizeof
(
uint64_t
)
*
8
));
*
bit
=
1
ULL
<<
(
id
%
(
sizeof
(
uint64_t
)
*
8
));
return
C_OK
;
return
C_OK
;
}
}
...
@@ -177,7 +177,7 @@ int ACLGetCommandBitCoordinates(unsigned long id, uint64_t *word, uint64_t *bit)
...
@@ -177,7 +177,7 @@ int ACLGetCommandBitCoordinates(unsigned long id, uint64_t *word, uint64_t *bit)
int
ACLGetUserCommandBit
(
user
*
u
,
unsigned
long
id
)
{
int
ACLGetUserCommandBit
(
user
*
u
,
unsigned
long
id
)
{
uint64_t
word
,
bit
;
uint64_t
word
,
bit
;
if
(
ACLGetCommandBitCoordinates
(
id
,
&
word
,
&
bit
)
==
C_ERR
)
return
0
;
if
(
ACLGetCommandBitCoordinates
(
id
,
&
word
,
&
bit
)
==
C_ERR
)
return
0
;
return
u
->
allowed_commands
[
word
]
&
bit
;
return
(
u
->
allowed_commands
[
word
]
&
bit
)
!=
0
;
}
}
/* When +@all or allcommands is given, we set a reserved bit as well that we
/* When +@all or allcommands is given, we set a reserved bit as well that we
...
...
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