summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>2014-10-09 02:43:43 +0000
committerderaadt <deraadt@openbsd.org>2014-10-09 02:43:43 +0000
commit915dd24721b69a7d42ce7decbae57058ca85a1cd (patch)
treef4dde4349b45b5f26499ee70bdc60b85eb945dbc
parentfairly obvious reallocarray() conversion, where the size is recalculated (diff)
downloadwireguard-openbsd-915dd24721b69a7d42ce7decbae57058ca85a1cd.tar.xz
wireguard-openbsd-915dd24721b69a7d42ce7decbae57058ca85a1cd.zip
obvious reallocarray() conversions
-rw-r--r--libexec/spamd-setup/spamd-setup.c13
-rw-r--r--libexec/spamd/grey.c12
-rw-r--r--libexec/spamd/spamd.c4
3 files changed, 15 insertions, 14 deletions
diff --git a/libexec/spamd-setup/spamd-setup.c b/libexec/spamd-setup/spamd-setup.c
index f2166e25041..7f8aa23b701 100644
--- a/libexec/spamd-setup/spamd-setup.c
+++ b/libexec/spamd-setup/spamd-setup.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: spamd-setup.c,v 1.38 2012/12/04 02:24:47 deraadt Exp $ */
+/* $OpenBSD: spamd-setup.c,v 1.39 2014/10/09 02:43:43 deraadt Exp $ */
/*
* Copyright (c) 2003 Bob Beck. All rights reserved.
@@ -143,7 +143,8 @@ range2cidrlist(struct cidr *list, int *cli, int *cls, u_int32_t start,
maxsize = MAX(maxsize, diff);
if (*cls <= *cli + 1) { /* one extra for terminator */
- tmp = realloc(list, (*cls + 32) * sizeof(struct cidr));
+ tmp = reallocarray(list, *cls + 32,
+ sizeof(struct cidr));
if (tmp == NULL)
errx(1, "malloc failed");
list = tmp;
@@ -481,7 +482,7 @@ add_blacklist(struct bl *bl, size_t *blc, size_t *bls, gzFile gzf, int white)
/* we assume that there is an IP for every 16 bytes */
if (*blc + bu / 8 >= *bls) {
*bls += bu / 8;
- blt = realloc(bl, *bls * sizeof(struct bl));
+ blt = reallocarray(bl, *bls, sizeof(struct bl));
if (blt == NULL) {
*bls -= bu / 8;
serrno = errno;
@@ -492,7 +493,7 @@ add_blacklist(struct bl *bl, size_t *blc, size_t *bls, gzFile gzf, int white)
for (i = 0; i <= bu; i++) {
if (*blc + 1 >= *bls) {
*bls += 1024;
- blt = realloc(bl, *bls * sizeof(struct bl));
+ blt = reallocarray(bl, *bls, sizeof(struct bl));
if (blt == NULL) {
*bls -= 1024;
serrno = errno;
@@ -837,8 +838,8 @@ main(int argc, char *argv[])
struct blacklist *tmp;
bls += 32;
- tmp = realloc(blists,
- bls * sizeof(struct blacklist));
+ tmp = reallocarray(blists, bls,
+ sizeof(struct blacklist));
if (tmp == NULL)
errx(1, "malloc failed");
blists = tmp;
diff --git a/libexec/spamd/grey.c b/libexec/spamd/grey.c
index f085832b598..d4715d5cd9a 100644
--- a/libexec/spamd/grey.c
+++ b/libexec/spamd/grey.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: grey.c,v 1.55 2013/11/27 21:25:25 deraadt Exp $ */
+/* $OpenBSD: grey.c,v 1.56 2014/10/09 02:43:43 deraadt Exp $ */
/*
* Copyright (c) 2004-2006 Bob Beck. All rights reserved.
@@ -413,8 +413,8 @@ addwhiteaddr(char *addr)
if (whitecount == whitealloc) {
char **tmp;
- tmp = realloc(whitelist,
- (whitealloc + 1024) * sizeof(char *));
+ tmp = reallocarray(whitelist,
+ whitealloc + 1024, sizeof(char *));
if (tmp == NULL) {
freeaddrinfo(res);
return(-1);
@@ -450,8 +450,8 @@ addtrapaddr(char *addr)
if (trapcount == trapalloc) {
char **tmp;
- tmp = realloc(traplist,
- (trapalloc + 1024) * sizeof(char *));
+ tmp = reallocarray(traplist,
+ trapalloc + 1024, sizeof(char *));
if (tmp == NULL) {
freeaddrinfo(res);
return(-1);
@@ -610,7 +610,7 @@ greyscan(char *dbname)
if (asiz < dbk.size + 1) {
char *tmp;
- tmp = realloc(a, dbk.size * 2);
+ tmp = reallocarray(a, dbk.size, 2);
if (tmp == NULL)
goto bad;
a = tmp;
diff --git a/libexec/spamd/spamd.c b/libexec/spamd/spamd.c
index e3262fbd939..ca6784a5611 100644
--- a/libexec/spamd/spamd.c
+++ b/libexec/spamd/spamd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: spamd.c,v 1.114 2014/03/26 13:09:02 gsoares Exp $ */
+/* $OpenBSD: spamd.c,v 1.115 2014/10/09 02:43:43 deraadt Exp $ */
/*
* Copyright (c) 2002-2007 Bob Beck. All rights reserved.
@@ -237,7 +237,7 @@ parse_configline(char *line)
if (ac == au) {
char **tmp;
- tmp = realloc(av, (ac + 2048) * sizeof(char *));
+ tmp = reallocarray(av, ac + 2048, sizeof(char *));
if (tmp == NULL) {
free(av);
av = NULL;