summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorCedric Berger <cedric@cvs.openbsd.org>2003-02-04 17:29:07 +0000
committerCedric Berger <cedric@cvs.openbsd.org>2003-02-04 17:29:07 +0000
commit5e46e06624305fff92f0f2eaa2809270fd7c5361 (patch)
treebc658c01fce25be5f9d8d6da42e8df9543ffb5e2 /sbin
parent94da1474fc44c7adb7b7f93dfc4e5c9797383f17 (diff)
use size_t for struct size and offset calculations.
check msize for overflow and realloc overflow.
Diffstat (limited to 'sbin')
-rw-r--r--sbin/pfctl/pfctl_table.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/sbin/pfctl/pfctl_table.c b/sbin/pfctl/pfctl_table.c
index 41d0a4008b7..199a6034ce4 100644
--- a/sbin/pfctl/pfctl_table.c
+++ b/sbin/pfctl/pfctl_table.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfctl_table.c,v 1.32 2003/02/04 12:10:02 cedric Exp $ */
+/* $OpenBSD: pfctl_table.c,v 1.33 2003/02/04 17:29:06 cedric Exp $ */
/*
* Copyright (c) 2002 Cedric Berger
@@ -56,7 +56,7 @@
extern void usage(void);
static int pfctl_table(int, char *[], char *, char *, char *, int);
-static void grow_buffer(int, int);
+static void grow_buffer(size_t, int);
static void print_table(struct pfr_table *, int);
static void print_tstats(struct pfr_tstats *, int);
static void load_addr(int, char *[], char *, int);
@@ -310,7 +310,7 @@ pfctl_table(int argc, char *argv[], char *tname, char *command,
}
void
-grow_buffer(int bs, int minsize)
+grow_buffer(size_t bs, int minsize)
{
assert(minsize == 0 || minsize > msize);
if (!msize) {
@@ -326,6 +326,8 @@ grow_buffer(int bs, int minsize)
msize *= 2;
else
msize = minsize;
+ if (msize < 0 || msize >= SIZE_T_MAX / bs)
+ err(1, "buffer overflow");
buffer.caddr = realloc(buffer.caddr, msize * bs);
if (buffer.caddr == NULL)
err(1, "realloc");