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
hiredis
Commits
257a9d40
Commit
257a9d40
authored
Nov 24, 2010
by
Pieter Noordhuis
Browse files
Set error on unexpected nesting of multi bulks
parent
d4058be7
Changes
2
Hide whitespace changes
Inline
Side-by-side
hiredis.c
View file @
257a9d40
...
@@ -294,6 +294,13 @@ static int processMultiBulkItem(redisReader *r) {
...
@@ -294,6 +294,13 @@ static int processMultiBulkItem(redisReader *r) {
long
elements
;
long
elements
;
int
root
=
0
;
int
root
=
0
;
/* Set error for nested multi bulks with depth > 1 */
if
(
r
->
ridx
==
2
)
{
redisSetReplyReaderError
(
r
,
sdscatprintf
(
sdsempty
(),
"No support for nested multi bulk replies with depth > 1"
));
return
-
1
;
}
if
((
p
=
readLine
(
r
,
NULL
))
!=
NULL
)
{
if
((
p
=
readLine
(
r
,
NULL
))
!=
NULL
)
{
elements
=
strtol
(
p
,
NULL
,
10
);
elements
=
strtol
(
p
,
NULL
,
10
);
root
=
(
r
->
ridx
==
0
);
root
=
(
r
->
ridx
==
0
);
...
...
test.c
View file @
257a9d40
...
@@ -256,6 +256,17 @@ static void test_reply_reader() {
...
@@ -256,6 +256,17 @@ static void test_reply_reader() {
strcasecmp
(
err
,
"Protocol error, got
\"
@
\"
as reply type byte"
)
==
0
);
strcasecmp
(
err
,
"Protocol error, got
\"
@
\"
as reply type byte"
)
==
0
);
redisReplyReaderFree
(
reader
);
redisReplyReaderFree
(
reader
);
test
(
"Set error on nested multi bulks with depth > 1: "
);
reader
=
redisReplyReaderCreate
();
redisReplyReaderFeed
(
reader
,(
char
*
)
"*1
\r\n
"
,
4
);
redisReplyReaderFeed
(
reader
,(
char
*
)
"*1
\r\n
"
,
4
);
redisReplyReaderFeed
(
reader
,(
char
*
)
"*1
\r\n
"
,
4
);
ret
=
redisReplyReaderGetReply
(
reader
,
NULL
);
err
=
redisReplyReaderGetError
(
reader
);
test_cond
(
ret
==
REDIS_ERR
&&
strncasecmp
(
err
,
"No support for"
,
14
)
==
0
);
redisReplyReaderFree
(
reader
);
test
(
"Works with NULL functions for reply: "
);
test
(
"Works with NULL functions for reply: "
);
reader
=
redisReplyReaderCreate
();
reader
=
redisReplyReaderCreate
();
redisReplyReaderSetReplyObjectFunctions
(
reader
,
NULL
);
redisReplyReaderSetReplyObjectFunctions
(
reader
,
NULL
);
...
...
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