summaryrefslogtreecommitdiffstats
path: root/sbin/ipfw
diff options
context:
space:
mode:
authorluigi <luigi@FreeBSD.org>2010-03-04 16:55:32 +0000
committerluigi <luigi@FreeBSD.org>2010-03-04 16:55:32 +0000
commitb486493f31704510ea9ba1a97eb1f59f7b828fd1 (patch)
tree7b8a906e27480678be5ce665531fe708b10afb90 /sbin/ipfw
parent9b5097a55ee3c152b4776bb49d9f1472c3a56d4c (diff)
downloadFreeBSD-src-b486493f31704510ea9ba1a97eb1f59f7b828fd1.zip
FreeBSD-src-b486493f31704510ea9ba1a97eb1f59f7b828fd1.tar.gz
fix handling of sets
Diffstat (limited to 'sbin/ipfw')
-rw-r--r--sbin/ipfw/ipfw2.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/sbin/ipfw/ipfw2.c b/sbin/ipfw/ipfw2.c
index 9adce1b..27c6b0a 100644
--- a/sbin/ipfw/ipfw2.c
+++ b/sbin/ipfw/ipfw2.c
@@ -1625,13 +1625,21 @@ ipfw_sets_handler(char *av[])
if (av[0] == NULL)
errx(EX_USAGE, "set needs command");
if (_substrcmp(*av, "show") == 0) {
- void *data;
+ void *data = NULL;
char const *msg;
-
- nbytes = sizeof(struct ip_fw);
+ int nalloc;
+
+ nalloc = nbytes = sizeof(struct ip_fw);
+ while (nbytes >= nalloc) {
+ if (data)
+ free(data);
+ nalloc = nalloc * 2 + 200;
+ nbytes = nalloc;
data = safe_calloc(1, nbytes);
if (do_cmd(IP_FW_GET, data, (uintptr_t)&nbytes) < 0)
err(EX_OSERR, "getsockopt(IP_FW_GET)");
+ }
+
bcopy(&((struct ip_fw *)data)->next_rule,
&set_disable, sizeof(set_disable));
@@ -1661,7 +1669,7 @@ ipfw_sets_handler(char *av[])
i = do_cmd(IP_FW_DEL, masks, sizeof(uint32_t));
} else if (_substrcmp(*av, "move") == 0) {
av++;
- if (!av[0] && _substrcmp(*av, "rule") == 0) {
+ if (av[0] && _substrcmp(*av, "rule") == 0) {
cmd = 2;
av++;
} else
@@ -1685,7 +1693,7 @@ ipfw_sets_handler(char *av[])
av++;
masks[0] = masks[1] = 0;
- while (!av[0]) {
+ while (av[0]) {
if (isdigit(**av)) {
i = atoi(*av);
if (i < 0 || i > RESVD_SET)
OpenPOWER on IntegriCloud