passwords printed in the crash log (#11930)

When the server crashes during the AUTH command, or another command with
an AUTH argument, the password was recorded in the log.

Now, when the `auth` keyword is detected (could be in HELLO or MIGRATE, etc),
the loop exits before printing any additional arguments.
This commit is contained in:
polaris-alioth 2023-03-20 14:18:38 +08:00 committed by GitHub
parent 6cf8fc08f5
commit 56eef6fb5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1859,11 +1859,17 @@ void logCurrentClient(client *cc, const char *title) {
client = catClientInfoString(sdsempty(),cc);
serverLog(LL_WARNING|LL_RAW,"%s\n", client);
sdsfree(client);
serverLog(LL_WARNING|LL_RAW,"argc: '%d'\n", cc->argc);
for (j = 0; j < cc->argc; j++) {
robj *decoded;
decoded = getDecodedObject(cc->argv[j]);
sds repr = sdscatrepr(sdsempty(),decoded->ptr, min(sdslen(decoded->ptr), 128));
serverLog(LL_WARNING|LL_RAW,"argv[%d]: '%s'\n", j, (char*)repr);
if (!strcasecmp(decoded->ptr, "auth") || !strcasecmp(decoded->ptr, "auth2")) {
sdsfree(repr);
decrRefCount(decoded);
break;
}
sdsfree(repr);
decrRefCount(decoded);
}