mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-10 00:57:02 +02:00
BUG/MINOR: cli: cli_snd_buf: preserve \r\n for payload lines
cli_snd_buf() analyzez input line by line. Before this patch it has always scanned a given line for the presence of '\r' followed by '\n'. This is only needed for strings, that contain the commands itself like "show ssl cert\n", "set ssl cert test.pem <<\n". In case of strings, which contain the command's payload, like "-----BEGIN CERTIFICATE-----\r\n", '\r\n' should be preserved as is. This patch fixes the GitHub issue #2818. This patch should be backported in v3.1 and in v3.0.
This commit is contained in:
parent
178109f608
commit
d60c893991
14
src/cli.c
14
src/cli.c
@ -962,19 +962,19 @@ size_t cli_snd_buf(struct appctx *appctx, struct buffer *buf, size_t count, unsi
|
|||||||
|
|
||||||
if (str[len-1] == '\n')
|
if (str[len-1] == '\n')
|
||||||
lf = 1;
|
lf = 1;
|
||||||
|
|
||||||
/* Remove the trailing \r, if any and add a null byte at the
|
|
||||||
* end. For normal mode, the trailing \n is removed, but we
|
|
||||||
* conserve if for payload mode.
|
|
||||||
*/
|
|
||||||
len--;
|
len--;
|
||||||
if (len && str[len-1] == '\r')
|
|
||||||
len--;
|
|
||||||
if (appctx->st1 & APPCTX_CLI_ST1_PAYLOAD) {
|
if (appctx->st1 & APPCTX_CLI_ST1_PAYLOAD) {
|
||||||
str[len+1] = '\0';
|
str[len+1] = '\0';
|
||||||
b_add(&appctx->inbuf, len+1);
|
b_add(&appctx->inbuf, len+1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
/* Remove the trailing \r, if any and add a null byte at the
|
||||||
|
* end. For normal mode, the trailing \n is removed, but we
|
||||||
|
* conserve \r\n or \n sequences for payload mode.
|
||||||
|
*/
|
||||||
|
if (len && str[len-1] == '\r')
|
||||||
|
len--;
|
||||||
str[len] = '\0';
|
str[len] = '\0';
|
||||||
b_add(&appctx->inbuf, len);
|
b_add(&appctx->inbuf, len);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user