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
bf9fd5ff
Commit
bf9fd5ff
authored
Apr 27, 2011
by
Pieter Noordhuis
Browse files
Check for \n after finding \r
parent
32f99c51
Changes
1
Show whitespace changes
Inline
Side-by-side
src/networking.c
View file @
bf9fd5ff
...
@@ -712,6 +712,10 @@ int processMultibulkBuffer(redisClient *c) {
...
@@ -712,6 +712,10 @@ int processMultibulkBuffer(redisClient *c) {
if
(
newline
==
NULL
)
if
(
newline
==
NULL
)
return
REDIS_ERR
;
return
REDIS_ERR
;
/* Buffer should also contain \n */
if
(
newline
-
(
c
->
querybuf
)
>
((
signed
)
sdslen
(
c
->
querybuf
)
-
2
))
return
REDIS_ERR
;
/* We know for sure there is a whole line since newline != NULL,
/* We know for sure there is a whole line since newline != NULL,
* so go ahead and find out the multi bulk length. */
* so go ahead and find out the multi bulk length. */
redisAssert
(
c
->
querybuf
[
0
]
==
'*'
);
redisAssert
(
c
->
querybuf
[
0
]
==
'*'
);
...
@@ -733,9 +737,6 @@ int processMultibulkBuffer(redisClient *c) {
...
@@ -733,9 +737,6 @@ int processMultibulkBuffer(redisClient *c) {
/* Setup argv array on client structure */
/* Setup argv array on client structure */
if
(
c
->
argv
)
zfree
(
c
->
argv
);
if
(
c
->
argv
)
zfree
(
c
->
argv
);
c
->
argv
=
zmalloc
(
sizeof
(
robj
*
)
*
c
->
multibulklen
);
c
->
argv
=
zmalloc
(
sizeof
(
robj
*
)
*
c
->
multibulklen
);
/* Search new newline */
newline
=
strchr
(
c
->
querybuf
+
pos
,
'\r'
);
}
}
redisAssert
(
c
->
multibulklen
>
0
);
redisAssert
(
c
->
multibulklen
>
0
);
...
@@ -743,7 +744,13 @@ int processMultibulkBuffer(redisClient *c) {
...
@@ -743,7 +744,13 @@ int processMultibulkBuffer(redisClient *c) {
/* Read bulk length if unknown */
/* Read bulk length if unknown */
if
(
c
->
bulklen
==
-
1
)
{
if
(
c
->
bulklen
==
-
1
)
{
newline
=
strchr
(
c
->
querybuf
+
pos
,
'\r'
);
newline
=
strchr
(
c
->
querybuf
+
pos
,
'\r'
);
if
(
newline
!=
NULL
)
{
if
(
newline
==
NULL
)
break
;
/* Buffer should also contain \n */
if
(
newline
-
(
c
->
querybuf
)
>
((
signed
)
sdslen
(
c
->
querybuf
)
-
2
))
break
;
if
(
c
->
querybuf
[
pos
]
!=
'$'
)
{
if
(
c
->
querybuf
[
pos
]
!=
'$'
)
{
addReplyErrorFormat
(
c
,
addReplyErrorFormat
(
c
,
"Protocol error: expected '$', got '%c'"
,
"Protocol error: expected '$', got '%c'"
,
...
@@ -758,12 +765,9 @@ int processMultibulkBuffer(redisClient *c) {
...
@@ -758,12 +765,9 @@ int processMultibulkBuffer(redisClient *c) {
setProtocolError
(
c
,
pos
);
setProtocolError
(
c
,
pos
);
return
REDIS_ERR
;
return
REDIS_ERR
;
}
}
pos
+=
newline
-
(
c
->
querybuf
+
pos
)
+
2
;
pos
+=
newline
-
(
c
->
querybuf
+
pos
)
+
2
;
c
->
bulklen
=
ll
;
c
->
bulklen
=
ll
;
}
else
{
/* No newline in current buffer, so wait for more data */
break
;
}
}
}
/* Read bulk argument */
/* Read bulk argument */
...
...
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