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.
This commit is contained in:
antirez 2013-03-04 19:45:36 +01:00
parent 3be893123f
commit d334897e80

View File

@ -63,9 +63,12 @@ int clusterLoadConfig(char *filename) {
/* Parse the file. Note that single liens of the cluster config file can /* 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. * 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. * This means in the worst possible case, half of the Redis slots will be
* To simplify we allocate 1024+REDIS_CLUSTER_SLOTS*16 bytes per line. */ * present in a single line, possibly in importing or migrating state, so
maxline = 1024+REDIS_CLUSTER_SLOTS*16; * 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); line = zmalloc(maxline);
while(fgets(line,maxline,fp) != NULL) { while(fgets(line,maxline,fp) != NULL) {
int argc; int argc;