]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: httpclient-cli: fix uninit variable in error label
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 19 May 2026 16:26:18 +0000 (18:26 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 19 May 2026 16:33:13 +0000 (18:33 +0200)
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.

src/httpclient_cli.c

index 8dfa72d9b7531d57d90e8b8aa8ed05d68b2adeb3..aa94136fe26bd8210483e2d6b4f296ad188c8f3f 100644 (file)
@@ -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;