summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2020-01-22 06:24:44 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2020-01-22 06:24:44 +0000
commit9dc81e8fbcf979fb5e756afcfb6bc1173d8a3228 (patch)
tree565e3a8aba44fba5394e9e9a1fb1f29178d7e465 /usr.sbin
parent2e89b5a761ff2101dd037353a778cf39b79432df (diff)
set array length after allocation succeeds so free path doesn't deref null.
ok deraadt
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/acme-client/json.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/usr.sbin/acme-client/json.c b/usr.sbin/acme-client/json.c
index a57820b3132..737275862b6 100644
--- a/usr.sbin/acme-client/json.c
+++ b/usr.sbin/acme-client/json.c
@@ -1,4 +1,4 @@
-/* $Id: json.c,v 1.14 2019/06/18 18:50:07 florian Exp $ */
+/* $Id: json.c,v 1.15 2020/01/22 06:24:43 tedu Exp $ */
/*
* Copyright (c) 2016 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -459,12 +459,13 @@ json_parse_order(struct jsmnn *n, struct order *order)
if ((array = json_getarray(n, "authorizations")) == NULL)
goto err;
- if ((order->authsz = array->fields) > 0) {
+ if (array->fields > 0) {
order->auths = calloc(sizeof(*order->auths), order->authsz);
if (order->auths == NULL) {
warn("malloc");
goto err;
}
+ order->authsz = array->fields;
}
for (i = 0; i < array->fields; i++) {