From d334897e80d026b0b7b66b4c8b1ff318c2caebce Mon Sep 17 00:00:00 2001 From: antirez Date: Mon, 4 Mar 2013 19:45:36 +0100 Subject: [PATCH] Cluster: fix maximum line length when loading config. There are pathological cases where the line can be even longer a single node may contain all the slots in importing/migrating state. --- src/cluster.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/cluster.c b/src/cluster.c index a89ef9d7b..6c946c154 100644 --- a/src/cluster.c +++ b/src/cluster.c @@ -63,9 +63,12 @@ int clusterLoadConfig(char *filename) { /* Parse the file. Note that single liens of the cluster config file can * be really long as they include all the hash slots of the node. - * This means in the worst possible case REDIS_CLUSTER_SLOTS/2 integers. - * To simplify we allocate 1024+REDIS_CLUSTER_SLOTS*16 bytes per line. */ - maxline = 1024+REDIS_CLUSTER_SLOTS*16; + * This means in the worst possible case, half of the Redis slots will be + * present in a single line, possibly in importing or migrating state, so + * together with the node ID of the sender/receiver. + * + * To simplify we allocate 1024+REDIS_CLUSTER_SLOTS*128 bytes per line. */ + maxline = 1024+REDIS_CLUSTER_SLOTS*128; line = zmalloc(maxline); while(fgets(line,maxline,fp) != NULL) { int argc;