From 56eef6fb5ab7a755485c19f358761954ca459472 Mon Sep 17 00:00:00 2001 From: polaris-alioth Date: Mon, 20 Mar 2023 14:18:38 +0800 Subject: [PATCH] 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. --- src/debug.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/debug.c b/src/debug.c index 41722a901..83f37cd3d 100644 --- a/src/debug.c +++ b/src/debug.c @@ -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); }