mirror of
https://github.com/fluencelabs/redis
synced 2025-03-30 22:31:03 +00:00
Cluster: Fix segfault if cluster config corrupt
This commit adds a size check after initial config line parsing to make sure we have *at least* 8 arguments per line. Also, instead of asserting for cluster->myself, we just test and error out normally (since the error does a hard exit anyway). Closes #1597
This commit is contained in:
parent
879e18b7ec
commit
60c448b584
@ -168,6 +168,9 @@ int clusterLoadConfig(char *filename) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Regular config lines have at least eight fields */
|
||||||
|
if (argc < 8) goto fmterr;
|
||||||
|
|
||||||
/* Create this node if it does not exist */
|
/* Create this node if it does not exist */
|
||||||
n = clusterLookupNode(argv[0]);
|
n = clusterLookupNode(argv[0]);
|
||||||
if (!n) {
|
if (!n) {
|
||||||
@ -268,11 +271,12 @@ int clusterLoadConfig(char *filename) {
|
|||||||
|
|
||||||
sdsfreesplitres(argv,argc);
|
sdsfreesplitres(argv,argc);
|
||||||
}
|
}
|
||||||
|
/* Config sanity check */
|
||||||
|
if (server.cluster->myself == NULL) goto fmterr;
|
||||||
|
|
||||||
zfree(line);
|
zfree(line);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
/* Config sanity check */
|
|
||||||
redisAssert(server.cluster->myself != NULL);
|
|
||||||
redisLog(REDIS_NOTICE,"Node configuration loaded, I'm %.40s", myself->name);
|
redisLog(REDIS_NOTICE,"Node configuration loaded, I'm %.40s", myself->name);
|
||||||
|
|
||||||
/* Something that should never happen: currentEpoch smaller than
|
/* Something that should never happen: currentEpoch smaller than
|
||||||
@ -287,7 +291,7 @@ fmterr:
|
|||||||
redisLog(REDIS_WARNING,
|
redisLog(REDIS_WARNING,
|
||||||
"Unrecoverable error: corrupted cluster config file.");
|
"Unrecoverable error: corrupted cluster config file.");
|
||||||
zfree(line);
|
zfree(line);
|
||||||
fclose(fp);
|
if (fp) fclose(fp);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user