svn commit: r273031 - projects/routing/sbin/ipfw
Alexander V. Chernikov
melifaro at FreeBSD.org
Mon Oct 13 11:16:45 UTC 2014
Author: melifaro
Date: Mon Oct 13 11:16:44 2014
New Revision: 273031
URL: https://svnweb.freebsd.org/changeset/base/273031
Log:
Report error and return non-zero exit code if zeroing
non-matched entries.
Found by: Oleg Ginzburg
Modified:
projects/routing/sbin/ipfw/ipfw2.c
Modified: projects/routing/sbin/ipfw/ipfw2.c
==============================================================================
--- projects/routing/sbin/ipfw/ipfw2.c Mon Oct 13 11:04:01 2014 (r273030)
+++ projects/routing/sbin/ipfw/ipfw2.c Mon Oct 13 11:16:44 2014 (r273031)
@@ -2111,13 +2111,19 @@ static int
do_range_cmd(int cmd, ipfw_range_tlv *rt)
{
ipfw_range_header rh;
+ size_t sz;
memset(&rh, 0, sizeof(rh));
memcpy(&rh.range, rt, sizeof(*rt));
rh.range.head.length = sizeof(*rt);
rh.range.head.type = IPFW_TLV_RANGE;
+ sz = sizeof(rh);
- return (do_set3(cmd, &rh.opheader, sizeof(rh)));
+ if (do_get3(cmd, &rh.opheader, &sz) != 0)
+ return (-1);
+ /* Save number of matched objects */
+ rt->new_set = rh.range.new_set;
+ return (0);
}
/*
@@ -4792,6 +4798,9 @@ ipfw_zero(int ac, char *av[], int optnam
warn("rule %u: setsockopt(IP_FW_X%s)",
arg, name);
failed = EX_UNAVAILABLE;
+ } else if (rt.new_set == 0) {
+ printf("Entry %d not found\n", arg);
+ failed = EX_UNAVAILABLE;
} else if (!co.do_quiet)
printf("Entry %d %s.\n", arg,
optname == IP_FW_XZERO ?
More information about the svn-src-projects
mailing list