]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: httpclient/cli: display junk characters in vsn
authorWilliam Lallemand <wlallemand@haproxy.org>
Wed, 16 Feb 2022 10:37:02 +0000 (11:37 +0100)
committerWilliam Lallemand <wlallemand@haproxy.org>
Wed, 16 Feb 2022 10:37:02 +0000 (11:37 +0100)
ist are not ended by '\0', leading to junk characters being displayed
when using %s for printing the HTTP start line.

Fix the issue by replacing %s by %.*s + istlen.

Must be backported in 2.5.

src/http_client.c

index 6645a494664a0726861bcb981328e7717dca6a9b..dacc326be6eb0a08c862f668a14fc219e33c78a5 100644 (file)
@@ -173,7 +173,8 @@ static int hc_cli_io_handler(struct appctx *appctx)
        if (!trash)
                goto out;
        if (appctx->ctx.cli.i0 & HC_CLI_F_RES_STLINE) {
-               chunk_appendf(trash, "%s %d %s\n",istptr(hc->res.vsn), hc->res.status, istptr(hc->res.reason));
+               chunk_appendf(trash, "%.*s %d %.*s\n", (unsigned int)istlen(hc->res.vsn), istptr(hc->res.vsn),
+                             hc->res.status, (unsigned int)istlen(hc->res.reason), istptr(hc->res.reason));
                if (ci_putchk(si_ic(si), trash) == -1)
                        si_rx_room_blk(si);
                appctx->ctx.cli.i0 &= ~HC_CLI_F_RES_STLINE;