Download raw body.
acme-client: close json memory leaks
On Tue, 7 Apr 2026 12:45:49 +0200
Theo Buehler <tb@theobuehler.org> wrote:
> Thanks. Yes, that's basically what I had in mind. Two more nits
Fixed now, thank you for the review!
diff --git usr.sbin/acme-client/json.c usr.sbin/acme-client/json.c
index 40812698a05..3d792d37763 100644
--- usr.sbin/acme-client/json.c
+++ usr.sbin/acme-client/json.c
@@ -412,7 +412,8 @@ json_parse_challenge(struct jsmnn *n, struct chng *p)
static enum orderstatus
json_parse_order_status(struct jsmnn *n)
{
- char *status;
+ char *status;
+ enum orderstatus rc;
if (n == NULL)
return ORDER_INVALID;
@@ -421,17 +422,20 @@ json_parse_order_status(struct jsmnn *n)
return ORDER_INVALID;
if (strcmp(status, "pending") == 0)
- return ORDER_PENDING;
+ rc = ORDER_PENDING;
else if (strcmp(status, "ready") == 0)
- return ORDER_READY;
+ rc = ORDER_READY;
else if (strcmp(status, "processing") == 0)
- return ORDER_PROCESSING;
+ rc = ORDER_PROCESSING;
else if (strcmp(status, "valid") == 0)
- return ORDER_VALID;
+ rc = ORDER_VALID;
else if (strcmp(status, "invalid") == 0)
- return ORDER_INVALID;
+ rc = ORDER_INVALID;
else
- return ORDER_INVALID;
+ rc = ORDER_INVALID;
+
+ free(status);
+ return rc;
}
/*
@@ -443,21 +447,18 @@ json_parse_order(struct jsmnn *n, struct order *order)
{
struct jsmnn *array;
size_t i;
- char *finalize, *str;
+ char *str;
order->status = json_parse_order_status(n);
if (n == NULL)
return 0;
- if ((finalize = json_getstr(n, "finalize")) == NULL) {
+ if ((order->finalize = json_getstr(n, "finalize")) == NULL) {
warnx("no finalize field in order response");
return 0;
}
- if ((order->finalize = strdup(finalize)) == NULL)
- goto err;
-
if ((array = json_getarray(n, "authorizations")) == NULL)
goto err;
@@ -488,12 +489,11 @@ err:
int
json_parse_upd_order(struct jsmnn *n, struct order *order)
{
- char *certificate;
order->status = json_parse_order_status(n);
- if ((certificate = json_getstr(n, "certificate")) != NULL) {
- if ((order->certificate = strdup(certificate)) == NULL)
- return 0;
- }
+
+ if ((order->certificate = json_getstr(n, "certificate")) != NULL)
+ return 0;
+
return 1;
}
@@ -508,7 +508,6 @@ json_free_order(struct order *order)
free(order->auths[i]);
free(order->auths);
- order->finalize = NULL;
order->auths = NULL;
order->authsz = 0;
}
diff --git usr.sbin/acme-client/netproc.c usr.sbin/acme-client/netproc.c
index 70a069bc095..46f413e110e 100644
--- usr.sbin/acme-client/netproc.c
+++ usr.sbin/acme-client/netproc.c
@@ -429,6 +429,7 @@ donewacc(struct conn *c, const struct capaths *p, const char *contact)
warnx("%s", error);
free(error);
}
+ free(detail);
}
} else if (lc != 200 && lc != 201)
warnx("%s: bad HTTP: %ld", p->newaccount, lc);
acme-client: close json memory leaks