From cc81c041857f68691551054ca6a6920b2dcb69ad Mon Sep 17 00:00:00 2001 From: Israel Lot Date: Tue, 12 Mar 2019 18:29:12 -0500 Subject: [PATCH] Replicas aren't allowed to run the replicaof command --- src/replication.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/replication.c b/src/replication.c index 2081b5d5..0e218936 100644 --- a/src/replication.c +++ b/src/replication.c @@ -2154,6 +2154,14 @@ void slaveofCommand(client *c) { } else { PORT_LONG port; + if (c->flags & CLIENT_SLAVE) + { + /* If a client is already a replica they cannot run this command, + * because it involves flushing all replicas (including this client) */ + addReplyError(c,"Command is not valid when client is a replica."); + return; + } + if ((getLongFromObjectOrReply(c, c->argv[2], &port, NULL) != C_OK)) return;