Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/cluster_legacy.c
Original file line number Diff line number Diff line change
Expand Up @@ -2197,12 +2197,6 @@ static int clusterStartHandshake(char *ip, int port, int cport) {
return 0;
}

/* Port sanity check */
if (port <= 0 || port > 65535 || cport <= 0 || cport > 65535) {
errno = EINVAL;
return 0;
}

/* Set norm_ip as the normalized string representation of the node
* IP address. */
memset(norm_ip, 0, NET_IP_STR_LEN);
Expand Down Expand Up @@ -6901,6 +6895,10 @@ int clusterCommandSpecial(client *c) {
addReplyErrorFormat(c, "Invalid base port specified: %s", (char *)c->argv[3]->ptr);
return 1;
}
if (port <= 0 || port > 65535) {
addReplyErrorFormat(c, "Port number is out of range");
return 1;
}

if (c->argc == 5) {
if (getLongLongFromObject(c->argv[4], &cport) != C_OK) {
Expand All @@ -6911,6 +6909,11 @@ int clusterCommandSpecial(client *c) {
cport = port + CLUSTER_PORT_INCR;
}

if (cport <= 0 || cport > 65535) {
addReplyErrorFormat(c, "Cluster bus port number is out of range");
return 1;
}

if (clusterStartHandshake(c->argv[2]->ptr, port, cport) == 0 && errno == EINVAL) {
addReplyErrorFormat(c, "Invalid node address specified: %s:%s", (char *)c->argv[2]->ptr,
(char *)c->argv[3]->ptr);
Expand Down