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