From: Amaury Denoyelle Date: Tue, 19 May 2026 16:26:18 +0000 (+0200) Subject: BUG/MINOR: httpclient-cli: fix uninit variable in error label X-Git-Tag: v3.4-dev13~37 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=50354f929dd22cd2c34db723918667050b20b9a8;p=thirdparty%2Fhaproxy.git BUG/MINOR: httpclient-cli: fix uninit variable in error label The following patch fixes a leak in case of httpclient_start() failure in the httpclient_cli code by adding httpclient_destroy() call on error path. c53256adbc17bb76840fdc8213cf8854454d850b BUG/MINOR: httpclient-cli: Destroy http-client context if failing to start it However, error label may be selected prior to httpclient allocation if CLI arguments are incorrect. This can cause a crash due to a deferencing of an uninitialized variable. This has been detected via a compilation error : src/httpclient_cli.c: In function 'hc_cli_parse': src/httpclient_cli.c:162:2: error: 'hc' may be used uninitialized in this function [-Werror=maybe-uninitialized] 162 | httpclient_destroy(hc); | ^~~~~~~~~~~~~~~~~~~~~~ This must be backported along the above patch, which is scheduled up to the 2.6 release. --- diff --git a/src/httpclient_cli.c b/src/httpclient_cli.c index 8dfa72d9b..aa94136fe 100644 --- a/src/httpclient_cli.c +++ b/src/httpclient_cli.c @@ -91,7 +91,7 @@ void hc_cli_res_end_cb(struct httpclient *hc) static int hc_cli_parse(char **args, char *payload, struct appctx *appctx, void *private) { struct hcli_svc_ctx *ctx = applet_reserve_svcctx(appctx, sizeof(*ctx)); - struct httpclient *hc; + struct httpclient *hc = NULL; char *err = NULL; enum http_meth_t meth; char *meth_str;