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
6e70c011
Commit
6e70c011
authored
Dec 08, 2013
by
Yossi Gottlieb
Browse files
Return proper error on requests with an unbalanced number of quotes.
parent
c590549e
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/networking.c
View file @
6e70c011
...
@@ -884,6 +884,11 @@ int processInlineBuffer(redisClient *c) {
...
@@ -884,6 +884,11 @@ int processInlineBuffer(redisClient *c) {
aux
=
sdsnewlen
(
c
->
querybuf
,
querylen
);
aux
=
sdsnewlen
(
c
->
querybuf
,
querylen
);
argv
=
sdssplitargs
(
aux
,
&
argc
);
argv
=
sdssplitargs
(
aux
,
&
argc
);
sdsfree
(
aux
);
sdsfree
(
aux
);
if
(
argv
==
NULL
)
{
addReplyError
(
c
,
"Protocol error: unbalanced quotes in request"
);
setProtocolError
(
c
,
0
);
return
REDIS_ERR
;
}
/* Leave data after the first line of the query in the buffer */
/* Leave data after the first line of the query in the buffer */
sdsrange
(
c
->
querybuf
,
querylen
+
2
,
-
1
);
sdsrange
(
c
->
querybuf
,
querylen
+
2
,
-
1
);
...
...
tests/unit/protocol.tcl
View file @
6e70c011
...
@@ -60,6 +60,14 @@ start_server {tags {"protocol"}} {
...
@@ -60,6 +60,14 @@ start_server {tags {"protocol"}} {
assert_error
"*wrong*arguments*ping*"
{
r ping x y z
}
assert_error
"*wrong*arguments*ping*"
{
r ping x y z
}
}
}
test
"Unbalanced number of quotes"
{
reconnect
r write
"set
\"\"\"
test-key
\"\"\"
test-value
\r\n
"
r write
"ping
\r\n
"
r flush
assert_error
"*unbalanced*"
{
r read
}
}
set c 0
set c 0
foreach seq
[
list
"
\x00
"
"*
\x00
"
"
$
\x00
"
]
{
foreach seq
[
list
"
\x00
"
"*
\x00
"
"
$
\x00
"
]
{
incr c
incr c
...
...
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