summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorTheo Buehler <tb@cvs.openbsd.org>2021-02-19 12:18:24 +0000
committerTheo Buehler <tb@cvs.openbsd.org>2021-02-19 12:18:24 +0000
commit294e46146c32c170d02ebef22b824e5aef7e7c2b (patch)
tree93ba687c5da657ae8519307cfd7c2c59cc90753b /usr.sbin
parent69bacbdfdae03b00eb0c622774395294072efd40 (diff)
Convert reallocarray + memset to recallocarray.
ok claudio
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/rpki-client/main.c8
-rw-r--r--usr.sbin/rpki-client/mft.c7
-rw-r--r--usr.sbin/rpki-client/roa.c7
3 files changed, 10 insertions, 12 deletions
diff --git a/usr.sbin/rpki-client/main.c b/usr.sbin/rpki-client/main.c
index a63bc15f245..cf4e154db70 100644
--- a/usr.sbin/rpki-client/main.c
+++ b/usr.sbin/rpki-client/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.102 2021/02/19 08:14:49 claudio Exp $ */
+/* $OpenBSD: main.c,v 1.103 2021/02/19 12:18:23 tb Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -267,12 +267,12 @@ repo_alloc(void)
{
struct repo *rp;
- rt.repos = reallocarray(rt.repos, rt.reposz + 1, sizeof(struct repo));
+ rt.repos = recallocarray(rt.repos, rt.reposz, rt.reposz + 1,
+ sizeof(struct repo));
if (rt.repos == NULL)
- err(1, "reallocarray");
+ err(1, "recallocarray");
rp = &rt.repos[rt.reposz++];
- memset(rp, 0, sizeof(struct repo));
rp->id = rt.reposz - 1;
return rp;
diff --git a/usr.sbin/rpki-client/mft.c b/usr.sbin/rpki-client/mft.c
index de903b5d65a..45c801cf6df 100644
--- a/usr.sbin/rpki-client/mft.c
+++ b/usr.sbin/rpki-client/mft.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mft.c,v 1.26 2021/02/16 07:58:30 job Exp $ */
+/* $OpenBSD: mft.c,v 1.27 2021/02/19 12:18:23 tb Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -193,13 +193,12 @@ mft_parse_filehash(struct parse *p, const ASN1_OCTET_STRING *os)
/* Insert the filename and hash value. */
- p->res->files = reallocarray(p->res->files, p->res->filesz + 1,
- sizeof(struct mftfile));
+ p->res->files = recallocarray(p->res->files, p->res->filesz,
+ p->res->filesz + 1, sizeof(struct mftfile));
if (p->res->files == NULL)
err(1, NULL);
fent = &p->res->files[p->res->filesz++];
- memset(fent, 0, sizeof(struct mftfile));
fent->file = fn;
fn = NULL;
diff --git a/usr.sbin/rpki-client/roa.c b/usr.sbin/rpki-client/roa.c
index 1ee9187e828..9cf8f22aafc 100644
--- a/usr.sbin/rpki-client/roa.c
+++ b/usr.sbin/rpki-client/roa.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: roa.c,v 1.14 2021/02/16 07:58:30 job Exp $ */
+/* $OpenBSD: roa.c,v 1.15 2021/02/19 12:18:23 tb Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -111,12 +111,11 @@ roa_parse_addr(const ASN1_OCTET_STRING *os, enum afi afi, struct parse *p)
/* FIXME: maximum check. */
}
- p->res->ips = reallocarray(p->res->ips,
- p->res->ipsz + 1, sizeof(struct roa_ip));
+ p->res->ips = recallocarray(p->res->ips, p->res->ipsz, p->res->ipsz + 1,
+ sizeof(struct roa_ip));
if (p->res->ips == NULL)
err(1, NULL);
res = &p->res->ips[p->res->ipsz++];
- memset(res, 0, sizeof(struct roa_ip));
res->addr = addr;
res->afi = afi;