[Bug 248608] [patch] off-by-one alignment in ipfw -t list
bugzilla-noreply at freebsd.org
bugzilla-noreply at freebsd.org
Tue Aug 11 20:14:37 UTC 2020
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=248608
Bug ID: 248608
Summary: [patch] off-by-one alignment in ipfw -t list
Product: Base System
Version: CURRENT
Hardware: Any
OS: Any
Status: New
Severity: Affects Some People
Priority: ---
Component: bin
Assignee: bugs at FreeBSD.org
Reporter: t at tstearns.com
Created attachment 217162
--> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=217162&action=edit
ipfw off-by-one patch
When I run `ipfw -t list` on release/12 or current, I get misaligned output
between lines that do and do not have a last match timestamp, like so:
00100 Tue Aug 11 03:03:26 2020 allow ip from any to any via lo0
00200 deny ip from any to 127.0.0.0/8
(specifically, the "allow" and "deny" strings do not line up)
This appears to be a simple off-by-one logic error in ipfw2.c. The routine
`ipfw_list` calculates the number of characters that a date string takes up,
called `twidth`, then prints one of the following:
If a match timestamp exists, then twidth date characters are printed, followed
by a space, followed by the rule string.
If a match timestamp does not exist, then twidth spaces are printed, followed
by the rule string.
The correct behavior would be to print twidth characters followed by a space
for both code paths, as is done in the attached patch. After applying this
patch locally, I get correct results:
00100 Tue Aug 11 03:03:26 2020 allow ip from any to any via lo0
00200 deny ip from any to 127.0.0.0/8
--
You are receiving this mail because:
You are the assignee for the bug.
More information about the freebsd-bugs
mailing list