struct set_cert_ctx {
struct ckch_store *old_ckchs;
struct ckch_store *new_ckchs;
- char *path;
};
/* CLI context used by "set ca-file" */
/* fallthrough */
case CERT_ST_FIN:
/* we achieved the transaction, we can set everything to NULL */
- ha_free(&ckchs_transaction.path);
ckchs_transaction.new_ckchs = NULL;
ckchs_transaction.old_ckchs = NULL;
+ ckchs_transaction.path = NULL;
goto end;
}
}
goto end;
}
- if (!ctx->path) {
- /* this is a new transaction, set the path of the transaction */
- ctx->path = strdup(ctx->old_ckchs->path);
- if (!ctx->path) {
- memprintf(&err, "%sCan't allocate memory\n", err ? err : "");
- errcode |= ERR_ALERT | ERR_FATAL;
- goto end;
- }
- }
-
old_ckchs = ctx->old_ckchs;
/* duplicate the ckch store */
/* if there wasn't a transaction, update the old ckchs */
if (!ckchs_transaction.old_ckchs) {
ckchs_transaction.old_ckchs = ctx->old_ckchs;
- ckchs_transaction.path = ctx->path;
+ ckchs_transaction.path = ctx->old_ckchs->path;
err = memprintf(&err, "Transaction created for certificate %s!\n", ckchs_transaction.path);
} else {
err = memprintf(&err, "Transaction updated for certificate %s!\n", ckchs_transaction.path);
ckch_store_free(ctx->new_ckchs);
ctx->new_ckchs = NULL;
ctx->old_ckchs = NULL;
- ha_free(&ctx->path);
-
HA_SPIN_UNLOCK(CKCH_LOCK, &ckch_lock);
return cli_dynerr(appctx, memprintf(&err, "%sCan't update %s!\n", err ? err : "", args[3]));
} else {
ckch_store_free(ckchs_transaction.new_ckchs);
ckchs_transaction.new_ckchs = NULL;
ckchs_transaction.old_ckchs = NULL;
- ha_free(&ckchs_transaction.path);
+ ckchs_transaction.path = NULL;
HA_SPIN_UNLOCK(CKCH_LOCK, &ckch_lock);