Skip to content

Commit 2c1da82

Browse files
Fix the check for ":0@0" in CLUSTER NODES result (#199)
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.
1 parent b2add9f commit 2c1da82

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

hircluster.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -960,8 +960,8 @@ dict *parse_cluster_nodes(redisClusterContext *cc, char *str, int str_len,
960960
goto error;
961961
}
962962

963-
// the address string is ":0", skip this node.
964-
if (sdslen(part[1]) == 2 && strcmp(part[1], ":0") == 0) {
963+
// if the address string starts with ":0", skip this node.
964+
if (sdslen(part[1]) >= 2 && memcmp(part[1], ":0", 2) == 0) {
965965
sdsfreesplitres(part, count_part);
966966
count_part = 0;
967967
part = NULL;

0 commit comments

Comments
 (0)