Skip to content

Commit d11f43d

Browse files
author
Meir Shpilraien (Spielrein)
authored
Merge branch 'master' into refactoring_rust_api
2 parents 091cfaa + f1bd1c0 commit d11f43d

File tree

2 files changed

+282
-229
lines changed

2 files changed

+282
-229
lines changed

src/cluster.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -856,8 +856,27 @@ static void MR_SetClusterData(RedisModuleString** argv, int argc){
856856

857857
addr = passEnd + 1;
858858

859-
char* ipEnd = strstr(addr, ":");
859+
if (addr[0] == '[') {
860+
addr += 1; /* skip ipv6 opener `[` */
861+
}
862+
863+
/* Find last `:` */
864+
char* iter = strstr(addr, ":");
865+
char* ipEnd = NULL;
866+
while (iter) {
867+
ipEnd = iter;
868+
iter++;
869+
iter = strstr(iter, ":");
870+
}
871+
872+
RedisModule_Assert(ipEnd);
873+
860874
size_t ipSize = ipEnd - addr;
875+
876+
if (addr[ipSize - 1] == ']') {
877+
--ipSize; /* Skip ipv6 closer `]` */
878+
}
879+
861880
char ip[ipSize + 1];
862881
memcpy(ip, addr, ipSize);
863882
ip[ipSize] = '\0';

0 commit comments

Comments
 (0)