aboutsummaryrefslogtreecommitdiff
path: root/contrib/ipfilter
diff options
context:
space:
mode:
authorCy Schubert <cy@FreeBSD.org>2017-03-16 04:40:07 +0000
committerCy Schubert <cy@FreeBSD.org>2017-03-16 04:40:07 +0000
commit3820c3aa3f7094bf2a52e3df57a182fcf2790f7d (patch)
tree4e94e84cef440db847f5167f424f14585ade60e8 /contrib/ipfilter
parent1f50ad62db8e9c3425ac0162be0645e7beeba1ce (diff)
Notes
Diffstat (limited to 'contrib/ipfilter')
-rw-r--r--contrib/ipfilter/ip_fil.c4
-rw-r--r--contrib/ipfilter/iplang/iplang_l.l3
-rw-r--r--contrib/ipfilter/ipsd/ipsd.c2
-rw-r--r--contrib/ipfilter/ipsd/ipsdr.c2
-rw-r--r--contrib/ipfilter/ipsend/lsock.c2
-rw-r--r--contrib/ipfilter/ipsend/sock.c4
-rw-r--r--contrib/ipfilter/lib/parsefields.c2
-rw-r--r--contrib/ipfilter/lib/parseipfexpr.c4
-rw-r--r--contrib/ipfilter/radix_ipf.c2
-rw-r--r--contrib/ipfilter/tools/ipf_y.y2
-rw-r--r--contrib/ipfilter/tools/ipfcomp.c2
-rw-r--r--contrib/ipfilter/tools/ipfstat.c4
12 files changed, 17 insertions, 16 deletions
diff --git a/contrib/ipfilter/ip_fil.c b/contrib/ipfilter/ip_fil.c
index 03e40935882b..f16c4fb8a1ea 100644
--- a/contrib/ipfilter/ip_fil.c
+++ b/contrib/ipfilter/ip_fil.c
@@ -317,8 +317,8 @@ get_unit(name, family)
} else {
old_ifneta = ifneta;
nifs++;
- ifneta = (struct ifnet **)realloc(ifneta,
- (nifs + 1) * sizeof(ifp));
+ ifneta = (struct ifnet **)reallocarray(ifneta, nifs + 1,
+ sizeof(ifp));
if (!ifneta) {
free(old_ifneta);
nifs = 0;
diff --git a/contrib/ipfilter/iplang/iplang_l.l b/contrib/ipfilter/iplang/iplang_l.l
index 029a4175bbec..0002db151c81 100644
--- a/contrib/ipfilter/iplang/iplang_l.l
+++ b/contrib/ipfilter/iplang/iplang_l.l
@@ -195,7 +195,8 @@ void push_proto()
if (!prstack)
prstack = (int *)malloc(sizeof(int));
else
- prstack = (int *)realloc((char *)prstack, numpr * sizeof(int));
+ prstack = (int *)reallocarray((char *)prstack, numpr,
+ sizeof(int));
prstack[numpr - 1] = oldipproto;
}
diff --git a/contrib/ipfilter/ipsd/ipsd.c b/contrib/ipfilter/ipsd/ipsd.c
index ce51c1b796d0..5269dab3df9d 100644
--- a/contrib/ipfilter/ipsd/ipsd.c
+++ b/contrib/ipfilter/ipsd/ipsd.c
@@ -129,7 +129,7 @@ int detect(ip, tcp)
if (++ihp->sd_cnt == ihp->sd_sz)
{
ihp->sd_sz += 8;
- sh = realloc(sh, ihp->sd_sz * sizeof(*sh));
+ sh = reallocarray(sh, ihp->sd_sz, sizeof(*sh));
ihp->sd_hit = sh;
}
qsort(sh, ihp->sd_cnt, sizeof(*sh), ipcmp);
diff --git a/contrib/ipfilter/ipsd/ipsdr.c b/contrib/ipfilter/ipsd/ipsdr.c
index e1c0c0aebc95..5adf076b8383 100644
--- a/contrib/ipfilter/ipsd/ipsdr.c
+++ b/contrib/ipfilter/ipsd/ipsdr.c
@@ -140,7 +140,7 @@ int detect(srcip, dport, date)
if (++ihp->sd_cnt == ihp->sd_sz)
{
ihp->sd_sz += 8;
- sh = realloc(sh, ihp->sd_sz * sizeof(*sh));
+ sh = reallocarray(sh, ihp->sd_sz, sizeof(*sh));
ihp->sd_hit = sh;
}
qsort(sh, ihp->sd_cnt, sizeof(*sh), ipcmp);
diff --git a/contrib/ipfilter/ipsend/lsock.c b/contrib/ipfilter/ipsend/lsock.c
index 5cf2bf7ff3da..245b2924ca06 100644
--- a/contrib/ipfilter/ipsend/lsock.c
+++ b/contrib/ipfilter/ipsend/lsock.c
@@ -163,7 +163,7 @@ struct sock *find_tcp(fd, ti)
return NULL;
fs = p->files;
- o = (struct file **)calloc(1, sizeof(*o) * (fs->count + 1));
+ o = (struct file **)calloc(fs->count + 1, sizeof(*o));
if (KMCPY(o, fs->fd, (fs->count + 1) * sizeof(*o)) == -1)
{
fprintf(stderr, "read(%#x,%#x,%d) - fd - failed\n",
diff --git a/contrib/ipfilter/ipsend/sock.c b/contrib/ipfilter/ipsend/sock.c
index 6d0f3dbac2bb..81e8ec3ef65f 100644
--- a/contrib/ipfilter/ipsend/sock.c
+++ b/contrib/ipfilter/ipsend/sock.c
@@ -226,7 +226,7 @@ struct tcpcb *find_tcp(fd, ti)
}
#endif
- o = (struct file **)calloc(1, sizeof(*o) * (up->u_lastfile + 1));
+ o = (struct file **)calloc(up->u_lastfile + 1, sizeof(*o));
if (KMCPY(o, up->u_ofile, (up->u_lastfile + 1) * sizeof(*o)) == -1)
{
fprintf(stderr, "read(%#x,%#x,%d) - u_ofile - failed\n",
@@ -330,7 +330,7 @@ struct tcpcb *find_tcp(tfd, ti)
i = NULL;
t = NULL;
- o = (struct file **)calloc(1, sizeof(*o) * (fd->fd_lastfile + 1));
+ o = (struct file **)calloc(fd->fd_lastfile + 1, sizeof(*o));
if (KMCPY(o, fd->fd_ofiles, (fd->fd_lastfile + 1) * sizeof(*o)) == -1)
{
fprintf(stderr, "read(%#lx,%#lx,%lu) - u_ofile - failed\n",
diff --git a/contrib/ipfilter/lib/parsefields.c b/contrib/ipfilter/lib/parsefields.c
index 241496c96da9..b64db32d6b12 100644
--- a/contrib/ipfilter/lib/parsefields.c
+++ b/contrib/ipfilter/lib/parsefields.c
@@ -31,7 +31,7 @@ wordtab_t *parsefields(table, arg)
if (fields == NULL) {
fields = malloc(2 * sizeof(*fields));
} else {
- fields = realloc(fields, (num + 1) * sizeof(*fields));
+ fields = reallocarray(fields, num + 1, sizeof(*fields));
}
if (t == NULL) {
diff --git a/contrib/ipfilter/lib/parseipfexpr.c b/contrib/ipfilter/lib/parseipfexpr.c
index 9a2a2071e9db..18958301b900 100644
--- a/contrib/ipfilter/lib/parseipfexpr.c
+++ b/contrib/ipfilter/lib/parseipfexpr.c
@@ -123,9 +123,9 @@ parseipfexpr(line, errorptr)
osize = asize;
asize += 4 + (items * e->ipoe_nbasearg * e->ipoe_argsize);
if (oplist == NULL)
- oplist = calloc(1, sizeof(int) * (asize + 2));
+ oplist = calloc(asize + 2, sizeof(int));
else
- oplist = realloc(oplist, sizeof(int) * (asize + 2));
+ oplist = reallocarray(oplist, asize + 2, sizeof(int));
if (oplist == NULL) {
error = "oplist alloc failed";
goto parseerror;
diff --git a/contrib/ipfilter/radix_ipf.c b/contrib/ipfilter/radix_ipf.c
index f145c38a94d6..1c9fa7c446c8 100644
--- a/contrib/ipfilter/radix_ipf.c
+++ b/contrib/ipfilter/radix_ipf.c
@@ -1192,7 +1192,7 @@ buildtab(void)
if (lines == 1)
tab = malloc(sizeof(*tab) * 2);
else
- tab = realloc(tab, (lines + 1) * sizeof(*tab));
+ tab = reallocarray(tab, lines + 1, sizeof(*tab));
tab[lines - 1].host = strdup(line);
s = strchr(tab[lines - 1].host, '/');
*s++ = '\0';
diff --git a/contrib/ipfilter/tools/ipf_y.y b/contrib/ipfilter/tools/ipf_y.y
index e0dc847a100e..7feb83e15b8f 100644
--- a/contrib/ipfilter/tools/ipf_y.y
+++ b/contrib/ipfilter/tools/ipf_y.y
@@ -2194,7 +2194,7 @@ char *phrase;
for (i = 0, s = strtok(phrase, " \r\n\t"); s != NULL;
s = strtok(NULL, " \r\n\t"), i++) {
- fb = realloc(fb, (i / 4 + 1) * sizeof(*fb));
+ fb = reallocarray(fb, i / 4 + 1, sizeof(*fb));
l = (u_32_t)strtol(s, NULL, 0);
switch (i & 3)
{
diff --git a/contrib/ipfilter/tools/ipfcomp.c b/contrib/ipfilter/tools/ipfcomp.c
index eba28ceb1d51..d41faa44e3b3 100644
--- a/contrib/ipfilter/tools/ipfcomp.c
+++ b/contrib/ipfilter/tools/ipfcomp.c
@@ -965,7 +965,7 @@ void printC(dir)
frgroup_t *g;
if (m == NULL)
- m = (mc_t *)calloc(1, sizeof(*m) * FRC_MAX);
+ m = (mc_t *)calloc(FRC_MAX, sizeof(*m));
for (g = groups; g != NULL; g = g->fg_next) {
if ((dir == 0) && ((g->fg_flags & FR_INQUE) != 0))
diff --git a/contrib/ipfilter/tools/ipfstat.c b/contrib/ipfilter/tools/ipfstat.c
index 3261cef8e4d2..3f0060189f23 100644
--- a/contrib/ipfilter/tools/ipfstat.c
+++ b/contrib/ipfilter/tools/ipfstat.c
@@ -1422,8 +1422,8 @@ static void topipstates(saddr, daddr, sport, dport, protocol, ver,
tsentry++;
if (!maxtsentries || tsentry == maxtsentries) {
maxtsentries += STGROWSIZE;
- tstable = realloc(tstable,
- maxtsentries * sizeof(statetop_t));
+ tstable = reallocarray(tstable, maxtsentries,
+ sizeof(statetop_t));
if (tstable == NULL) {
perror("realloc");
exit(-1);