Avoid Accessing Arguments Out Of Bounds In handleDebugClusterCommand (#14242)
CI / test-ubuntu-latest (push) Has been cancelled Details
CI / test-sanitizer-address (push) Has been cancelled Details
CI / build-debian-old (push) Has been cancelled Details
CI / build-macos-latest (push) Has been cancelled Details
CI / build-32bit (push) Has been cancelled Details
CI / build-libc-malloc (push) Has been cancelled Details
CI / build-centos-jemalloc (push) Has been cancelled Details
CI / build-old-chain-jemalloc (push) Has been cancelled Details
Codecov / code-coverage (push) Has been cancelled Details
External Server Tests / test-external-standalone (push) Has been cancelled Details
External Server Tests / test-external-cluster (push) Has been cancelled Details
External Server Tests / test-external-nodebug (push) Has been cancelled Details
Spellcheck / Spellcheck (push) Has been cancelled Details

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
1 changed files with 3 additions and 3 deletions

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