aboutsummaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorAndrey V. Elsukov <ae@FreeBSD.org>2020-09-11 10:07:09 +0000
committerAndrey V. Elsukov <ae@FreeBSD.org>2020-09-11 10:07:09 +0000
commitb876085f5589f4e6d531d97ad902c5730ec55339 (patch)
tree5b8c745ed033aa7515c752e1722623257375cadd /sbin
parenteffd82ca7059b5830435eea6bf8861f8cb625751 (diff)
downloadsrc-b876085f5589f4e6d531d97ad902c5730ec55339.tar.gz
src-b876085f5589f4e6d531d97ad902c5730ec55339.zip
Fix compatibility regression after r364117.
Properly handle the case, when some opcode keywords follow after the `frag` opcode without additional options. Reported by: Evgeniy Khramtsov <evgeniy at khramtsov org>
Notes
Notes: svn path=/head/; revision=365628
Diffstat (limited to 'sbin')
-rw-r--r--sbin/ipfw/ipfw2.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/sbin/ipfw/ipfw2.c b/sbin/ipfw/ipfw2.c
index b5d559a48055..67303d8bb1e7 100644
--- a/sbin/ipfw/ipfw2.c
+++ b/sbin/ipfw/ipfw2.c
@@ -4560,17 +4560,24 @@ read_options:
fill_cmd(cmd, O_DIVERTED, 0, 2);
break;
- case TOK_FRAG:
- fill_flags_cmd(cmd, O_FRAG, f_ipoff, *av);
- /*
- * Compatibility: no argument after "frag"
- * keyword equals to "frag offset".
- */
- if (cmd->arg1 == 0)
- cmd->arg1 = 0x1;
- else
+ case TOK_FRAG: {
+ uint32_t set = 0, clear = 0;
+
+ if (*av != NULL && fill_flags(f_ipoff, *av, NULL,
+ &set, &clear) == 0)
av++;
+ else {
+ /*
+ * Compatibility: no argument after "frag"
+ * keyword equals to "frag offset".
+ */
+ set = 0x01;
+ clear = 0;
+ }
+ fill_cmd(cmd, O_FRAG, 0,
+ (set & 0xff) | ( (clear & 0xff) << 8));
break;
+ }
case TOK_LAYER2:
fill_cmd(cmd, O_LAYER2, 0, 0);