]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: acme: warning ‘ctx’ may be used uninitialized
authorWilliam Lallemand <wlallemand@irq6.net>
Fri, 21 Nov 2025 21:59:47 +0000 (22:59 +0100)
committerWilliam Lallemand <wlallemand@irq6.net>
Fri, 21 Nov 2025 22:04:16 +0000 (23:04 +0100)
Please compiler with maybe-uninitialized warning

src/acme.c: In function ‘cli_acme_chall_ready_parse’:
include/haproxy/task.h:215:9: error: ‘ctx’ may be used uninitialized [-Werror=maybe-uninitialized]
  215 |         _task_wakeup(t, f, MK_CALLER(WAKEUP_TYPE_TASK_WAKEUP, 0, 0))
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/acme.c:2903:17: note: in expansion of macro ‘task_wakeup’
 2903 |                 task_wakeup(ctx->task, TASK_WOKEN_MSG);
      |                 ^~~~~~~~~~~
src/acme.c:2862:26: note: ‘ctx’ was declared here
 2862 |         struct acme_ctx *ctx;
      |                          ^~~

Backport to 3.2.

src/acme.c

index 61cbb5bb147bc0ebd6671a7cb8588f5dd25a1f12..17c8b1a5e5ac5417859059575d4e8ef5589a26f7 100644 (file)
@@ -2859,7 +2859,7 @@ static int cli_acme_chall_ready_parse(char **args, char *payload, struct appctx
        char *msg = NULL;
        const char *crt;
        const char *dns;
-       struct acme_ctx *ctx;
+       struct acme_ctx *ctx = NULL;
        struct acme_auth *auth;
        int found = 0;
        int remain = 0;
@@ -2897,13 +2897,14 @@ static int cli_acme_chall_ready_parse(char **args, char *payload, struct appctx
                if (!msg)
                        memprintf(&msg, "Couldn't find the ACME task using crt \"%s\" and dns \"%s\" !\n", crt, dns);
                goto err;
-       }
-
-       if (!remain) {
-               task_wakeup(ctx->task, TASK_WOKEN_MSG);
-               return cli_dynmsg(appctx, LOG_INFO, memprintf(&msg, "%d '%s' challenge(s) ready! All challenges ready, starting challenges validation!", found, dns));
        } else {
-               return cli_dynmsg(appctx, LOG_INFO, memprintf(&msg, "%d '%s' challenge(s) ready! Remaining challenges to deploy: %d", found, dns, remain));
+               if (!remain) {
+                       if (ctx)
+                               task_wakeup(ctx->task, TASK_WOKEN_MSG);
+                       return cli_dynmsg(appctx, LOG_INFO, memprintf(&msg, "%d '%s' challenge(s) ready! All challenges ready, starting challenges validation!", found, dns));
+               } else {
+                       return cli_dynmsg(appctx, LOG_INFO, memprintf(&msg, "%d '%s' challenge(s) ready! Remaining challenges to deploy: %d", found, dns, remain));
+               }
        }
 
 err: