diff options
author | Geoff Garside <geoff@geoffgarside.co.uk> | 2011-06-18 18:59:07 +0100 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2013-07-08 15:51:37 +0200 |
commit | 6e894f02cf305ac0e86413e96f51b03571fdbebf (patch) | |
tree | a91922efae2fc8eefec50ced40cd83fa4185d734 | |
parent | 693b640510cb8e09b69e42205ec87a104fa79b57 (diff) | |
download | redis-6e894f02cf305ac0e86413e96f51b03571fdbebf.tar.gz |
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.
-rw-r--r-- | src/cluster.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/cluster.c b/src/cluster.c index 7531ab7c5..e60d82a64 100644 --- a/src/cluster.c +++ b/src/cluster.c @@ -758,7 +758,7 @@ void nodeIp2String(char *buf, clusterLink *link) { if (getpeername(link->fd, (struct sockaddr*) &sa, &salen) == -1) 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) { /* Finally add the node to the cluster with a random name, this * will get fixed in the first handshake (ping/pong). */ 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; clusterAddNode(n); addReply(c,shared.ok); |