Commit 6e894f02 authored by Geoff Garside's avatar Geoff Garside Committed by antirez
Browse files

Fix cluster.c inet_ntop use of sizeof(n->ip).

Using sizeof with an array will only return expected results if the
array is created in the scope of the function where sizeof is used. This
commit changes the inet_ntop calls so that they use the fixed buffer
value as defined in redis.h which is 16.
parent 693b6405
...@@ -758,7 +758,7 @@ void nodeIp2String(char *buf, clusterLink *link) { ...@@ -758,7 +758,7 @@ void nodeIp2String(char *buf, clusterLink *link) {
if (getpeername(link->fd, (struct sockaddr*) &sa, &salen) == -1) if (getpeername(link->fd, (struct sockaddr*) &sa, &salen) == -1)
redisPanic("getpeername() failed."); redisPanic("getpeername() failed.");
inet_ntop(sa.sin_family,(void*)&(sa.sin_addr),buf,sizeof(link->node->ip)); inet_ntop(sa.sin_family,(void*)&(sa.sin_addr),buf,16);
} }
...@@ -2084,7 +2084,7 @@ void clusterCommand(redisClient *c) { ...@@ -2084,7 +2084,7 @@ void clusterCommand(redisClient *c) {
/* Finally add the node to the cluster with a random name, this /* Finally add the node to the cluster with a random name, this
* will get fixed in the first handshake (ping/pong). */ * will get fixed in the first handshake (ping/pong). */
n = createClusterNode(NULL,REDIS_NODE_HANDSHAKE|REDIS_NODE_MEET); n = createClusterNode(NULL,REDIS_NODE_HANDSHAKE|REDIS_NODE_MEET);
inet_ntop(sa.sin_family,(void*)&(sa.sin_addr),n->ip,sizeof(n->ip)); inet_ntop(sa.sin_family,(void*)&(sa.sin_addr),n->ip,16);
n->port = port; n->port = port;
clusterAddNode(n); clusterAddNode(n);
addReply(c,shared.ok); addReply(c,shared.ok);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment