-/* $OpenBSD: mft.c,v 1.36 2021/07/13 18:39:39 job Exp $ */
+/* $OpenBSD: mft.c,v 1.37 2021/09/08 16:37:20 claudio Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
}
/* Insert the filename and hash value. */
-
- 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++];
fent->file = fn;
goto out;
}
+ p->res->files = calloc(sk_ASN1_TYPE_num(seq), sizeof(struct mftfile));
+ if (p->res->files == NULL)
+ err(1, NULL);
+
for (i = 0; i < sk_ASN1_TYPE_num(seq); i++) {
t = sk_ASN1_TYPE_value(seq, i);
if (t->type != V_ASN1_SEQUENCE) {
-/* $OpenBSD: roa.c,v 1.23 2021/08/01 22:29:49 job Exp $ */
+/* $OpenBSD: roa.c,v 1.24 2021/09/08 16:37:20 claudio Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
}
}
- 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++];
res->addr = addr;
goto out;
}
+ /* will be called multiple times so use recallocarray */
+ p->res->ips = recallocarray(p->res->ips, p->res->ipsz,
+ p->res->ipsz + sk_ASN1_TYPE_num(sseq), sizeof(struct roa_ip));
+ if (p->res->ips == NULL)
+ err(1, NULL);
+
for (i = 0; i < sk_ASN1_TYPE_num(sseq); i++) {
t = sk_ASN1_TYPE_value(sseq, i);
if (t->type != V_ASN1_SEQUENCE) {