From 6ca0dd05f44e2baf9db686957dffca358bceb425 Mon Sep 17 00:00:00 2001 From: "Alexander V. Chernikov" Date: Mon, 13 Oct 2014 12:49:04 +0000 Subject: [PATCH] Show error when deleting non-existing rule number. Found by: Oleg Ginzburg --- sbin/ipfw/ipfw2.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/sbin/ipfw/ipfw2.c b/sbin/ipfw/ipfw2.c index ac79ef8c3d62..242451922fd2 100644 --- a/sbin/ipfw/ipfw2.c +++ b/sbin/ipfw/ipfw2.c @@ -3009,7 +3009,6 @@ fill_flags_cmd(ipfw_insn *cmd, enum ipfw_opcodes opcode, void ipfw_delete(char *av[]) { - uint32_t rulenum; int i; int exitval = EX_OK; int do_set = 0; @@ -3059,7 +3058,15 @@ ipfw_delete(char *av[]) if (i != 0) { exitval = EX_UNAVAILABLE; warn("rule %u: setsockopt(IP_FW_XDEL)", - rulenum); + rt.start_rule); + } else if (rt.new_set == 0) { + exitval = EX_UNAVAILABLE; + if (rt.start_rule != rt.end_rule) + warnx("no rules rules in %u-%u range", + rt.start_rule, rt.end_rule); + else + warnx("rule %u not found", + rt.start_rule); } } }