Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
101d4bf8
"vscode:/vscode.git/clone" did not exist on "f2bc198d40355cdfb628f626408b4f54a4939b8d"
Commit
101d4bf8
authored
Nov 05, 2013
by
antirez
Browse files
Use strtoul() instead of sscanf() in SCAN implementation.
parent
bf79c0cd
Changes
1
Show whitespace changes
Inline
Side-by-side
src/db.c
View file @
101d4bf8
...
@@ -364,7 +364,7 @@ void scanCallback(void *privdata, const dictEntry *de) {
...
@@ -364,7 +364,7 @@ void scanCallback(void *privdata, const dictEntry *de) {
void
scanGenericCommand
(
redisClient
*
c
,
robj
*
o
)
{
void
scanGenericCommand
(
redisClient
*
c
,
robj
*
o
)
{
int
rv
;
int
rv
;
int
i
,
j
;
int
i
,
j
;
char
buf
[
REDIS_LONGSTR_SIZE
];
char
buf
[
REDIS_LONGSTR_SIZE
]
,
*
eptr
;
list
*
keys
=
listCreate
();
list
*
keys
=
listCreate
();
listNode
*
node
,
*
nextnode
;
listNode
*
node
,
*
nextnode
;
unsigned
long
cursor
=
0
;
unsigned
long
cursor
=
0
;
...
@@ -381,9 +381,12 @@ void scanGenericCommand(redisClient *c, robj *o) {
...
@@ -381,9 +381,12 @@ void scanGenericCommand(redisClient *c, robj *o) {
/* Set i to the first option argument. The previous one is the cursor. */
/* Set i to the first option argument. The previous one is the cursor. */
i
=
(
o
==
NULL
)
?
2
:
3
;
/* Skip the key argument if needed. */
i
=
(
o
==
NULL
)
?
2
:
3
;
/* Skip the key argument if needed. */
/* Use sscanf because we need an *unsigned* long */
/* Use strtoul() because we need an *unsigned* long, so
rv
=
sscanf
(
c
->
argv
[
i
-
1
]
->
ptr
,
"%lu"
,
&
cursor
);
* getLongLongFromObject() does not cover the whole cursor space. */
if
(
rv
!=
1
)
{
errno
=
0
;
cursor
=
strtoul
(
c
->
argv
[
i
-
1
]
->
ptr
,
&
eptr
,
10
);
if
(
isspace
(((
char
*
)
c
->
argv
[
i
-
1
])[
0
])
||
eptr
[
0
]
!=
'\0'
||
errno
==
ERANGE
)
{
addReplyError
(
c
,
"invalid cursor"
);
addReplyError
(
c
,
"invalid cursor"
);
goto
cleanup
;
goto
cleanup
;
}
}
...
...
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