From ff2f0b092c24d5cc590ff1eb596fc0865e0fb721 Mon Sep 17 00:00:00 2001 From: kei-nan Date: Fri, 1 Aug 2025 06:53:56 +0300 Subject: [PATCH] Avoid Accessing Arguments Out Of Bounds In handleDebugClusterCommand (#14242) Noticed we assume there are at least 3 arguments since we access to index 2 in the if and only later check the argc. Moved the argc check to the start of the if so the code will be a bit safer. --- src/cluster_legacy.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cluster_legacy.c b/src/cluster_legacy.c index 5f547812a..8a72867d1 100644 --- a/src/cluster_legacy.c +++ b/src/cluster_legacy.c @@ -5897,9 +5897,9 @@ int clusterNodeIsMaster(clusterNode *n) { } int handleDebugClusterCommand(client *c) { - if (strcasecmp(c->argv[1]->ptr, "CLUSTERLINK") || - strcasecmp(c->argv[2]->ptr, "KILL") || - c->argc != 5) { + if (c->argc != 5 || + strcasecmp(c->argv[1]->ptr, "CLUSTERLINK") || + strcasecmp(c->argv[2]->ptr, "KILL")) { return 0; }