Merge pull request #5579 from yongman/fix-rediscli-pointer-access

Fix pointer access and memory leak in redis-cli.
This commit is contained in:
Salvatore Sanfilippo 2018-11-20 10:38:59 +01:00 committed by GitHub
commit 8acc07e6f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2829,7 +2829,7 @@ static int clusterManagerMigrateKeysInSlot(clusterManagerNode *source,
if (err != NULL) { if (err != NULL) {
*err = zmalloc((reply->len + 1) * sizeof(char)); *err = zmalloc((reply->len + 1) * sizeof(char));
strcpy(*err, reply->str); strcpy(*err, reply->str);
CLUSTER_MANAGER_PRINT_REPLY_ERROR(source, err); CLUSTER_MANAGER_PRINT_REPLY_ERROR(source, *err);
} }
goto next; goto next;
} }
@ -2947,7 +2947,7 @@ static int clusterManagerMoveSlot(clusterManagerNode *source,
if (err != NULL) { if (err != NULL) {
*err = zmalloc((r->len + 1) * sizeof(char)); *err = zmalloc((r->len + 1) * sizeof(char));
strcpy(*err, r->str); strcpy(*err, r->str);
CLUSTER_MANAGER_PRINT_REPLY_ERROR(n, err); CLUSTER_MANAGER_PRINT_REPLY_ERROR(n, *err);
} }
} }
freeReplyObject(r); freeReplyObject(r);
@ -5196,10 +5196,13 @@ static int clusterManagerCommandSetTimeout(int argc, char **argv) {
n->port); n->port);
ok_count++; ok_count++;
continue; continue;
reply_err: reply_err:;
int need_free = 0;
if (err == NULL) err = ""; if (err == NULL) err = "";
else need_free = 1;
clusterManagerLogErr("ERR setting node-timeot for %s:%d: %s\n", n->ip, clusterManagerLogErr("ERR setting node-timeot for %s:%d: %s\n", n->ip,
n->port, err); n->port, err);
if (need_free) zfree(err);
err_count++; err_count++;
} }
clusterManagerLogInfo(">>> New node timeout set. %d OK, %d ERR.\n", clusterManagerLogInfo(">>> New node timeout set. %d OK, %d ERR.\n",