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.
This commit is contained in:
Oran Agra 2022-04-26 00:34:01 +03:00 committed by GitHub
parent 119ec91a5a
commit 79ffc3524d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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