From 5bdd72bea77d4bb237441c9a671e80edcdc998ad Mon Sep 17 00:00:00 2001 From: Omer Shadmi <76992134+oshadmi@users.noreply.github.com> Date: Thu, 10 Feb 2022 13:22:57 +0200 Subject: [PATCH] Use binary representation for key values dumped to crash log (#10275) Use binary representation for key values dumped crash to log, so that if they contain null chars they're still printed correctly. Additionally limit their length to 128 chars Co-authored-by: Oran Agra --- src/debug.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/debug.c b/src/debug.c index c4f30a3ae..3e941292b 100644 --- a/src/debug.c +++ b/src/debug.c @@ -1729,10 +1729,10 @@ void logCurrentClient(void) { sdsfree(client); for (j = 0; j < cc->argc; j++) { robj *decoded; - decoded = getDecodedObject(cc->argv[j]); - serverLog(LL_WARNING|LL_RAW,"argv[%d]: '%s'\n", j, - (char*)decoded->ptr); + sds repr = sdscatrepr(sdsempty(),decoded->ptr, min(sdslen(decoded->ptr), 128)); + serverLog(LL_WARNING|LL_RAW,"argv[%d]: '%s'\n", j, (char*)repr); + sdsfree(repr); decrRefCount(decoded); } /* Check if the first argument, usually a key, is found inside the