]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: cli: Report an error to user if command or payload is too big
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 28 Mar 2024 13:52:29 +0000 (14:52 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 28 Mar 2024 16:28:20 +0000 (17:28 +0100)
Too big command, larger than a buffer, was silently rejected by the CLI
applet. It was handled as an error and the connection was closed, but no
error message was reported to user to notify him. Now an error is reported
before closing. It is only displayed if the chunk buffer used by the CLI
applet is full and no delimiter (\n or ;) is found to mark the end of the
command. It works for a simple command but also for a command with a huge
payload.

This patch could be backported to all stable versions.

src/cli.c

index 89a22278864ee410690b710b1ac3ba7852174c30..7c856bb318577dfe784850db542e24fa90e70b73 100644 (file)
--- a/src/cli.c
+++ b/src/cli.c
@@ -997,6 +997,11 @@ static void cli_io_handler(struct appctx *appctx)
                        len = reql - 1;
                        if (str[len] != '\n' && str[len] != ';') {
                                se_fl_set(appctx->sedesc, SE_FL_ERROR);
+                               if (reql == appctx->chunk->size - appctx->chunk->data - 1) {
+                                       cli_err(appctx, "The command is too big for the buffer size. Please change tune.bufsize in the configuration to use a bigger command.\n");
+                                       co_skip(sc_oc(sc), co_data(sc_oc(sc)));
+                                       goto cli_output;
+                               }
                                appctx->st0 = CLI_ST_END;
                                continue;
                        }
@@ -1084,7 +1089,7 @@ static void cli_io_handler(struct appctx *appctx)
                        struct cli_print_ctx *ctx;
                        const char *msg;
                        int sev;
-
+               cli_output:
                        switch (appctx->st0) {
                        case CLI_ST_PROMPT:
                                break;