From: Willy Tarreau Date: Wed, 1 Jul 2020 05:02:42 +0000 (+0200) Subject: BUG/MINOR: proxy: fix dump_server_state()'s misuse of the trash X-Git-Tag: v2.2-dev12~39 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6ff8143f7;p=thirdparty%2Fhaproxy.git BUG/MINOR: proxy: fix dump_server_state()'s misuse of the trash dump_server_state() claims to dump into a buffer but instead it writes into a buffer then dumps the trash into the channel, so it only supports being called with buf=&trash and doesn't need this buffer. There doesn't seem to be any current impact of this mistake since the function is called from one location only. A backport may be performed if it helps fixing other bugs but it will not fix an existing bug by itself. --- diff --git a/src/proxy.c b/src/proxy.c index 6aa5629b13..3fb4b6d075 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -1745,14 +1745,14 @@ static int cli_parse_show_servers(char **args, char *payload, struct appctx *app return 0; } -/* dumps server state information into for all the servers found in backend cli.p0. +/* dumps server state information for all the servers found in backend cli.p0. * These information are all the parameters which may change during HAProxy runtime. * By default, we only export to the last known server state file format. * These information can be used at next startup to recover same level of server state. * It uses the proxy pointer from cli.p0, the proxy's id from cli.i0 and the server's * pointer from cli.p1. */ -static int dump_servers_state(struct stream_interface *si, struct buffer *buf) +static int dump_servers_state(struct stream_interface *si) { struct appctx *appctx = __objt_appctx(si->end); struct proxy *px = appctx->ctx.cli.p0; @@ -1794,7 +1794,7 @@ static int dump_servers_state(struct stream_interface *si, struct buffer *buf) if (srv->srvrq && srv->srvrq->name) srvrecord = srv->srvrq->name; - chunk_appendf(buf, + chunk_appendf(&trash, "%d %s " "%d %s %s " "%d %d %d %d %ld " @@ -1846,7 +1846,7 @@ static int cli_io_handler_servers_state(struct appctx *appctx) curproxy = appctx->ctx.cli.p0; /* servers are only in backends */ if (curproxy->cap & PR_CAP_BE) { - if (!dump_servers_state(si, &trash)) + if (!dump_servers_state(si)) return 0; } /* only the selected proxy is dumped */