MEDIUM: cli: Report a warning to user if command or payload is too big

Instead of silently closing the connection when a too big payload is parsed,
a warning is now displayed and then the connection is closed.
This commit is contained in:
Christopher Faulet 2024-02-20 19:14:41 +01:00
parent 8d0902d84a
commit 54bf7ffa70
1 changed files with 13 additions and 3 deletions

View File

@ -943,10 +943,15 @@ size_t cli_snd_buf(struct appctx *appctx, struct buffer *buf, size_t count, unsi
len = b_getline(buf, ret, count, str, b_room(&appctx->inbuf) - 1);
if (!len) {
if (!b_room(buf) || (count > b_room(&appctx->inbuf) - 1) || (flags & CO_SFL_LAST_DATA)) {
b_reset(&appctx->inbuf);
applet_set_eos(appctx);
if (!b_room(buf) || (count > b_room(&appctx->inbuf) - 1)) {
cli_err(appctx, "command or payload too big.\n");
applet_set_error(appctx);
b_reset(&appctx->inbuf);
}
else if ((flags & CO_SFL_LAST_DATA)) {
applet_set_error(appctx);
b_reset(&appctx->inbuf);
appctx->st0 = CLI_ST_END;
}
break;
}
@ -1150,6 +1155,11 @@ static void cli_io_handler(struct appctx *appctx)
appctx->t->expire = TICK_ETERNITY;
appctx->st0 = CLI_ST_PROMPT;
}
if (applet_fl_test(appctx, APPCTX_FL_ERR_PENDING)) {
appctx->st0 = CLI_ST_END;
continue;
}
break;
case CLI_ST_CALLBACK: /* use custom pointer */