From: William Lallemand Date: Wed, 16 Apr 2025 15:54:34 +0000 (+0200) Subject: MINOR: acme: free acme_ctx once the task is done X-Git-Tag: v3.2-dev11~47 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8efafe76a31a3f971fd23acfff2aa5d7a0366014;p=thirdparty%2Fhaproxy.git MINOR: acme: free acme_ctx once the task is done Free the acme_ctx task context once the task is done. It frees everything but the config and the httpclient, everything else is free. The ckch_store is freed in case of error, but when the task is successful, the ptr is set to NULL to prevent the free once inserted in the tree. --- diff --git a/src/acme.c b/src/acme.c index 47520a738..1e45b2d44 100644 --- a/src/acme.c +++ b/src/acme.c @@ -491,6 +491,44 @@ INITCALL1(STG_REGISTER, cfg_register_keywords, &cfg_kws_acme); REGISTER_CONFIG_SECTION("acme", cfg_parse_acme, cfg_postsection_acme); +/* free acme_ctx and its content + * + * Only acme_cfg and the httpclient is not free + * + */ +static void acme_ctx_destroy(struct acme_ctx *ctx) +{ + struct acme_auth *auth; + + istfree(&ctx->ressources.newNonce); + istfree(&ctx->ressources.newAccount); + istfree(&ctx->ressources.newOrder); + istfree(&ctx->nonce); + istfree(&ctx->kid); + istfree(&ctx->order); + + auth = ctx->auths; + while (auth) { + struct acme_auth *next; + + istfree(&auth->auth); + istfree(&auth->chall); + istfree(&auth->token); + next = auth->next; + free(auth); + auth = next; + } + + istfree(&ctx->finalize); + istfree(&ctx->certificate); + + ckch_store_free(ctx->store); + + X509_REQ_free(ctx->req); + + free(ctx); +} + static void acme_httpclient_end(struct httpclient *hc) { struct task *task = hc->caller; @@ -627,6 +665,8 @@ int acme_update_certificate(struct task *task, struct acme_ctx *ctx, char **errm send_log(NULL, LOG_NOTICE,"acme: %s: Successful update of the certificate.\n", ctx->store->path); + ctx->store = NULL; + ret = 0; error: @@ -1695,6 +1735,7 @@ retry: return task; end: + acme_ctx_destroy(ctx); task_destroy(task); task = NULL;