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
5bbb09ed
Commit
5bbb09ed
authored
Jan 19, 2016
by
antirez
Browse files
Cluster: check packets length before accessing far fields.
parent
751b5666
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/cluster.c
View file @
5bbb09ed
...
...
@@ -1542,9 +1542,6 @@ int clusterProcessPacket(clusterLink *link) {
clusterMsg
*
hdr
=
(
clusterMsg
*
)
link
->
rcvbuf
;
uint32_t
totlen
=
ntohl
(
hdr
->
totlen
);
uint16_t
type
=
ntohs
(
hdr
->
type
);
uint16_t
flags
=
ntohs
(
hdr
->
flags
);
uint64_t
senderCurrentEpoch
=
0
,
senderConfigEpoch
=
0
;
clusterNode
*
sender
;
server
.
cluster
->
stats_bus_messages_received
++
;
serverLog
(
LL_DEBUG
,
"--- Processing packet of type %d, %lu bytes"
,
...
...
@@ -1552,9 +1549,17 @@ int clusterProcessPacket(clusterLink *link) {
/* Perform sanity checks */
if
(
totlen
<
16
)
return
1
;
/* At least signature, version, totlen, count. */
if
(
ntohs
(
hdr
->
ver
)
!=
CLUSTER_PROTO_VER
)
return
1
;
/* Can't handle versions other than the current one.*/
if
(
totlen
>
sdslen
(
link
->
rcvbuf
))
return
1
;
if
(
ntohs
(
hdr
->
ver
)
!=
CLUSTER_PROTO_VER
)
{
/* Can't handle messages of different versions. */
return
1
;
}
uint16_t
flags
=
ntohs
(
hdr
->
flags
);
uint64_t
senderCurrentEpoch
=
0
,
senderConfigEpoch
=
0
;
clusterNode
*
sender
;
if
(
type
==
CLUSTERMSG_TYPE_PING
||
type
==
CLUSTERMSG_TYPE_PONG
||
type
==
CLUSTERMSG_TYPE_MEET
)
{
...
...
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