From 631d656a94bdc8e23bcfaad3e64cb8210cc03aa9 Mon Sep 17 00:00:00 2001 From: antirez Date: Tue, 9 Jul 2013 11:32:52 +0200 Subject: [PATCH] All IP string repr buffers are now REDIS_IP_STR_LEN bytes. --- src/cluster.c | 2 +- src/networking.c | 5 ++--- src/redis.c | 2 +- src/sentinel.c | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/cluster.c b/src/cluster.c index 195cfe5d..76ab6711 100644 --- a/src/cluster.c +++ b/src/cluster.c @@ -306,7 +306,7 @@ void freeClusterLink(clusterLink *link) { void clusterAcceptHandler(aeEventLoop *el, int fd, void *privdata, int mask) { int cport, cfd; - char cip[128]; /* Could use INET6_ADDRSTRLEN here, but its smaller */ + char cip[REDIS_IP_STR_LEN]; clusterLink *link; REDIS_NOTUSED(el); REDIS_NOTUSED(mask); diff --git a/src/networking.c b/src/networking.c index b220055f..59f05643 100644 --- a/src/networking.c +++ b/src/networking.c @@ -552,7 +552,7 @@ static void acceptCommonHandler(int fd, int flags) { void acceptTcpHandler(aeEventLoop *el, int fd, void *privdata, int mask) { int cport, cfd; - char cip[128]; /* Could use INET6_ADDRSTRLEN here, but its smaller */ + char cip[REDIS_IP_STR_LEN]; REDIS_NOTUSED(el); REDIS_NOTUSED(mask); REDIS_NOTUSED(privdata); @@ -1210,8 +1210,7 @@ void clientCommand(redisClient *c) { } else if (!strcasecmp(c->argv[1]->ptr,"kill") && c->argc == 3) { listRewind(server.clients,&li); while ((ln = listNext(&li)) != NULL) { - /* addr size 64 > INET6_ADDRSTRLEN + : + strlen("65535") */ - char ip[INET6_ADDRSTRLEN], addr[64]; + char ip[REDIS_IP_STR_LEN], addr[REDIS_IP_STR_LEN+64]; int port; client = listNodeValue(ln); diff --git a/src/redis.c b/src/redis.c index a2bcdd6d..11c69629 100644 --- a/src/redis.c +++ b/src/redis.c @@ -2435,7 +2435,7 @@ sds genRedisInfoString(char *section) { while((ln = listNext(&li))) { redisClient *slave = listNodeValue(ln); char *state = NULL; - char ip[INET6_ADDRSTRLEN]; + char ip[REDIS_IP_STR_LEN]; int port; long lag = 0; diff --git a/src/sentinel.c b/src/sentinel.c index e89199fe..eb729966 100644 --- a/src/sentinel.c +++ b/src/sentinel.c @@ -1837,7 +1837,7 @@ void sentinelPingInstance(sentinelRedisInstance *ri) { (now - ri->last_pub_time) > SENTINEL_PUBLISH_PERIOD) { /* PUBLISH hello messages only to masters. */ - char ip[INET6_ADDRSTRLEN]; + char ip[REDIS_IP_STR_LEN]; if (anetSockName(ri->cc->c.fd,ip,sizeof(ip),NULL) != -1) { char myaddr[128];