Fixed memory write error in clusterManagerGetConfigSignature

This commit is contained in:
artix 2018-02-28 11:49:10 +01:00
parent 2f056b8331
commit fb41b8bb9c

View File

@ -2295,7 +2295,7 @@ static void clusterManagerShowNodes(void) {
while ((ln = listNext(&li)) != NULL) { while ((ln = listNext(&li)) != NULL) {
clusterManagerNode *node = ln->value; clusterManagerNode *node = ln->value;
sds info = clusterManagerNodeInfo(node, 0); sds info = clusterManagerNodeInfo(node, 0);
printf("%s\n", info); printf("%s\n", (char *) info);
sdsfree(info); sdsfree(info);
} }
} }
@ -2916,8 +2916,8 @@ static sds clusterManagerGetConfigSignature(clusterManagerNode *node) {
line = p + 1; line = p + 1;
if (i == 0) { if (i == 0) {
nodename = token; nodename = token;
tot_size = p - token; tot_size = (p - token);
name_len = tot_size; name_len = tot_size++; // Make room for ':' in tot_size
} else if (i == 8) break; } else if (i == 8) break;
i++; i++;
} }
@ -2951,6 +2951,7 @@ static sds clusterManagerGetConfigSignature(clusterManagerNode *node) {
node_count++; node_count++;
node_configs = node_configs =
zrealloc(node_configs, (node_count * sizeof(char *))); zrealloc(node_configs, (node_count * sizeof(char *)));
/* Make room for '|' separators. */
tot_size += (sizeof(char) * (c - 1)); tot_size += (sizeof(char) * (c - 1));
char *cfg = zmalloc((sizeof(char) * tot_size) + 1); char *cfg = zmalloc((sizeof(char) * tot_size) + 1);
memcpy(cfg, nodename, name_len); memcpy(cfg, nodename, name_len);
@ -3760,7 +3761,7 @@ static int clusterManagerCommandReshard(int argc, char **argv) {
opts, &err); opts, &err);
if (!result) { if (!result) {
if (err != NULL) { if (err != NULL) {
clusterManagerLogErr("\n%s\n", err); //clusterManagerLogErr("\n%s\n", err);
zfree(err); zfree(err);
} }
goto cleanup; goto cleanup;