Commit 63075b81 authored by caozb's avatar caozb Committed by Oran Agra
Browse files

ignore slaveof no one in redis.conf (#7842)



when slaveof config is "no one", reset any pre-existing config and resume.

also solve a memory leak if slaveof appears twice.
and fail loading if port number is out of range or not an integer.
Co-authored-by: default avatarcaozhengbin <caozb@yidingyun.com>
Co-authored-by: default avatarOran Agra <oran@redislabs.com>
(cherry picked from commit a295770e)
parent 94180837
......@@ -464,8 +464,17 @@ void loadServerConfigFromString(char *config) {
} else if ((!strcasecmp(argv[0],"slaveof") ||
!strcasecmp(argv[0],"replicaof")) && argc == 3) {
slaveof_linenum = linenum;
sdsfree(server.masterhost);
if (!strcasecmp(argv[1], "no") && !strcasecmp(argv[2], "one")) {
server.masterhost = NULL;
continue;
}
server.masterhost = sdsnew(argv[1]);
server.masterport = atoi(argv[2]);
char *ptr;
server.masterport = strtol(argv[2], &ptr, 10);
if (server.masterport < 0 || server.masterport > 65535 || *ptr != '\0') {
err = "Invalid master port"; goto loaderr;
}
server.repl_state = REPL_STATE_CONNECT;
} else if (!strcasecmp(argv[0],"requirepass") && argc == 2) {
if (strlen(argv[1]) > CONFIG_AUTHPASS_MAX_LEN) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment