Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Cluster Bus Port out of range error message for Cluster Meet command #1686

Merged
merged 5 commits into from
Feb 27, 2025
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Just check port and cport one place
Signed-off-by: hwware <[email protected]>
hwware committed Feb 26, 2025
commit b5e4e19e52d567849d93a8acee16b0cf9b644d21
27 changes: 0 additions & 27 deletions src/cluster.c
Original file line number Diff line number Diff line change
@@ -777,33 +777,6 @@ int isValidAuxString(char *s, unsigned int length) {
return 1;
}

int parseAndValidateConnectionPorts(client *c, long long *port, long long *cport) {
if (getLongLongFromObject(c->argv[3], port) != C_OK) {
addReplyErrorFormat(c, "Invalid base port specified: %s", (char *)c->argv[3]->ptr);
return C_ERR;
}
if (*port <= 0 || *port > 65535) {
addReplyErrorFormat(c, "Port number is out of range");
return C_ERR;
}

if (c->argc == 5) {
if (getLongLongFromObject(c->argv[4], cport) != C_OK) {
addReplyErrorFormat(c, "Invalid bus port specified: %s", (char *)c->argv[4]->ptr);
return C_ERR;
}
} else {
*cport = *port + CLUSTER_PORT_INCR;
}

if (*cport <= 0 || *cport > 65535) {
addReplyErrorFormat(c, "Cport number is out of range");
return C_ERR;
}

return C_OK;
}

void clusterCommandMyId(client *c) {
char *name = clusterNodeGetName(getMyClusterNode());
if (name) {
1 change: 0 additions & 1 deletion src/cluster.h
Original file line number Diff line number Diff line change
@@ -133,5 +133,4 @@ int isNodeAvailable(clusterNode *node);
long long getNodeReplicationOffset(clusterNode *node);
sds aggregateClientOutputBuffer(client *c);
void resetClusterStats(void);
int parseAndValidateConnectionPorts(client *c, long long *port, long long *cport);
#endif /* __CLUSTER_H */
21 changes: 20 additions & 1 deletion src/cluster_legacy.c
Original file line number Diff line number Diff line change
@@ -6891,7 +6891,26 @@ int clusterCommandSpecial(client *c) {
/* CLUSTER MEET <ip> <port> [cport] */
long long port, cport;

if (parseAndValidateConnectionPorts(c, &port, &cport) == C_ERR) {
if (getLongLongFromObject(c->argv[3], &port) != C_OK) {
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) {
addReplyErrorFormat(c, "Invalid bus port specified: %s", (char *)c->argv[4]->ptr);
return 1;
}
} else {
cport = port + CLUSTER_PORT_INCR;
}

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