From 30f666ef4ab7bbba103be35a944f99f2383a6cb6 Mon Sep 17 00:00:00 2001 From: John Sully Date: Sat, 9 Mar 2019 11:03:59 -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 a3110661e..f2e55e7b4 100644 --- a/src/replication.c +++ b/src/replication.c @@ -2031,6 +2031,14 @@ void replicaofCommand(client *c) { } else { 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; -- GitLab