From 79ffc3524dc3d1222685cacc236f417d09459bae Mon Sep 17 00:00:00 2001 From: Oran Agra Date: Tue, 26 Apr 2022 00:34:01 +0300 Subject: [PATCH] fix broken protocol regression from #10612 (#10639) A change in #10612 introduced a regression. when replying with garbage bytes to the caller, we must make sure it doesn't include any newlines. in the past it called rejectCommandFormat which did that trick. but now it calls rejectCommandSds, which doesn't, so we need to make sure to sanitize the sds. --- src/server.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/server.c b/src/server.c index b3106d0f7d..47907a4bd6 100644 --- a/src/server.c +++ b/src/server.c @@ -3520,6 +3520,9 @@ int commandCheckExistence(client *c, sds *err) { (char*)c->argv[0]->ptr, args); sdsfree(args); } + /* Make sure there are no newlines in the string, otherwise invalid protocol + * is emitted (The args come from the user, they may contain any character). */ + sdsmapchars(*err, "\r\n", " ", 2); return 0; }