mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-22 06:11:32 +02:00
BUG/MINOR: mworker/cli: fix the escaping in the master CLI
The master CLI must not do the escaping since it forwards the commands to another CLI. It should be able to split into words by taking care of the escaping, but must not remove the forwarded backslashes. This fix do the same thing as the previous patch applied to the cli_parse_request() function, by taking care of the escaping during the word split, but it also remove the part which was removing the backslashes from the forwarded command.
This commit is contained in:
parent
b08c6d06e7
commit
fe249c3df5
28
src/cli.c
28
src/cli.c
@ -2074,29 +2074,25 @@ int pcli_parse_request(struct stream *s, struct channel *req, char **errmsg, int
|
|||||||
|
|
||||||
/* splits the command in words */
|
/* splits the command in words */
|
||||||
while (i < MAX_STATS_ARGS && p < end) {
|
while (i < MAX_STATS_ARGS && p < end) {
|
||||||
int j, k;
|
|
||||||
|
|
||||||
/* skip leading spaces/tabs */
|
/* skip leading spaces/tabs */
|
||||||
p += strspn(p, " \t");
|
p += strspn(p, " \t");
|
||||||
if (!*p)
|
if (!*p)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
args[i] = p;
|
args[i] = p;
|
||||||
p += strcspn(p, " \t");
|
while (1) {
|
||||||
|
p += strcspn(p, " \t\\");
|
||||||
|
/* escaped chars using backlashes (\) */
|
||||||
|
if (*p == '\\') {
|
||||||
|
if (!*++p)
|
||||||
|
break;
|
||||||
|
if (!*++p)
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
*p++ = 0;
|
*p++ = 0;
|
||||||
|
|
||||||
/* unescape backslashes (\) */
|
|
||||||
for (j = 0, k = 0; args[i][k]; k++) {
|
|
||||||
if (args[i][k] == '\\') {
|
|
||||||
if (args[i][k + 1] == '\\')
|
|
||||||
k++;
|
|
||||||
else
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
args[i][j] = args[i][k];
|
|
||||||
j++;
|
|
||||||
}
|
|
||||||
args[i][j] = 0;
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user