summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2019-12-20 12:29:02 +0100
committerantirez <antirez@gmail.com>2019-12-20 12:29:02 +0100
commit324e22accf457edc996971bc97f5474349cd7c4c (patch)
tree8935da8115e1b545c8d9370b95619cd39dcbc858
parentd3a9dff6b95eb2ec16e432dd102202694dfc285a (diff)
downloadredis-324e22accf457edc996971bc97f5474349cd7c4c.tar.gz
Fix ip and missing mode in RM_GetClusterNodeInfo().
-rw-r--r--src/module.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/module.c b/src/module.c
index 33b69f8c2..705ffec2c 100644
--- a/src/module.c
+++ b/src/module.c
@@ -5082,10 +5082,13 @@ int RM_GetClusterNodeInfo(RedisModuleCtx *ctx, const char *id, char *ip, char *m
UNUSED(ctx);
clusterNode *node = clusterLookupNode(id);
- if (node->flags & (CLUSTER_NODE_NOADDR|CLUSTER_NODE_HANDSHAKE))
+ if (node == NULL ||
+ node->flags & (CLUSTER_NODE_NOADDR|CLUSTER_NODE_HANDSHAKE))
+ {
return REDISMODULE_ERR;
+ }
- if (ip) memcpy(ip,node->name,REDISMODULE_NODE_ID_LEN);
+ if (ip) strncpy(ip,node->ip,NET_IP_STR_LEN);
if (master_id) {
/* If the information is not available, the function will set the