Skip to content

Commit

Permalink
Fix the check for ":0@0" in CLUSTER NODES result (#199)
Browse files Browse the repository at this point in the history
Fix the check for the `ip:port@cport` part when parsing a line in the CLUSTER NODES result. The current implementation assumes that the entire part is only 2 characters when the IP and port are not set (IP is empty and port is 0). However, this is incorrect because the `@cport` is also present in Redis 4+ so the current check fails. Additionally, there may be an optional `,hostname` as well which is not accounted for.
  • Loading branch information
KevinLussier-Netskope authored Feb 9, 2024
1 parent b2add9f commit 2c1da82
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions hircluster.c
Original file line number Diff line number Diff line change
Expand Up @@ -960,8 +960,8 @@ dict *parse_cluster_nodes(redisClusterContext *cc, char *str, int str_len,
goto error;
}

// the address string is ":0", skip this node.
if (sdslen(part[1]) == 2 && strcmp(part[1], ":0") == 0) {
// if the address string starts with ":0", skip this node.
if (sdslen(part[1]) >= 2 && memcmp(part[1], ":0", 2) == 0) {
sdsfreesplitres(part, count_part);
count_part = 0;
part = NULL;
Expand Down

0 comments on commit 2c1da82

Please sign in to comment.