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.
This commit is contained in:
kei-nan 2025-08-01 06:53:56 +03:00 committed by GitHub
parent c55e33a99f
commit ff2f0b092c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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;
}