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
042776af
Commit
042776af
authored
Aug 22, 2013
by
antirez
Browse files
Cluster: fix CLUSTER MEET ip address validation.
This was broken by the IPv6 support patches.
parent
9cf30132
Changes
1
Show whitespace changes
Inline
Side-by-side
src/cluster.c
View file @
042776af
...
...
@@ -2082,8 +2082,15 @@ void clusterCommand(redisClient *c) {
long port;
/* Perform sanity checks on IP/port */
if
((
inet_pton
(
AF_INET
,
c
->
argv
[
0
]
->
ptr
,
&
(((
struct
sockaddr_in
*
)
&
sa
)
->
sin_addr
))
||
inet_pton
(
AF_INET6
,
c
->
argv
[
0
]
->
ptr
,
&
(((
struct
sockaddr_in6
*
)
&
sa
)
->
sin6_addr
)))
==
0
)
{
if (inet_pton(AF_INET,c->argv[2]->ptr,
&(((struct sockaddr_in *)&sa)->sin_addr)))
{
sa.ss_family = AF_INET;
} else if (inet_pton(AF_INET6,c->argv[2]->ptr,
&(((struct sockaddr_in6 *)&sa)->sin6_addr)))
{
sa.ss_family = AF_INET6;
} else {
addReplyError(c,"Invalid IP address in MEET");
return;
}
...
...
@@ -2097,9 +2104,17 @@ void clusterCommand(redisClient *c) {
/* Finally add the node to the cluster with a random name, this
* will get fixed in the first handshake (ping/pong). */
n = createClusterNode(NULL,REDIS_NODE_HANDSHAKE|REDIS_NODE_MEET);
sa
.
ss_family
==
AF_INET
?
inet_ntop
(
AF_INET
,(
void
*
)
&
(((
struct
sockaddr_in
*
)
&
sa
)
->
sin_addr
),
n
->
ip
,
REDIS_CLUSTER_IPLEN
)
:
inet_ntop
(
AF_INET6
,(
void
*
)
&
(((
struct
sockaddr_in6
*
)
&
sa
)
->
sin6_addr
),
n
->
ip
,
REDIS_CLUSTER_IPLEN
);
/* Set node->ip as the normalized string representation of the node
* IP address. */
if (sa.ss_family == AF_INET)
inet_ntop(AF_INET,
(void*)&(((struct sockaddr_in *)&sa)->sin_addr),
n->ip,REDIS_CLUSTER_IPLEN);
else
inet_ntop(AF_INET6,
(void*)&(((struct sockaddr_in6 *)&sa)->sin6_addr),
n->ip,REDIS_CLUSTER_IPLEN);
n->port = port;
clusterAddNode(n);
addReply(c,shared.ok);
...
...
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