Summary: | [patch] off-by-one alignment in ipfw -t list | ||||||
---|---|---|---|---|---|---|---|
Product: | Base System | Reporter: | Taylor Stearns <t> | ||||
Component: | bin | Assignee: | Ed Maste <emaste> | ||||
Status: | Closed FIXED | ||||||
Severity: | Affects Some People | CC: | emaste | ||||
Priority: | --- | ||||||
Version: | CURRENT | ||||||
Hardware: | Any | ||||||
OS: | Any | ||||||
Attachments: |
|
A commit references this bug: Author: emaste Date: Mon Aug 17 18:53:23 UTC 2020 New revision: 364321 URL: https://svnweb.freebsd.org/changeset/base/364321 Log: ipfw: line up `ipfw -t list` with and without timestamp From the PR: 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) PR: 248608 Submitted by: Taylor Stearns MFC after: 3 days Changes: head/sbin/ipfw/ipfw2.c A commit references this bug: Author: emaste Date: Fri Aug 21 19:28:27 UTC 2020 New revision: 364461 URL: https://svnweb.freebsd.org/changeset/base/364461 Log: MFC r364321: ipfw: line up `ipfw -t list` with and without timestamp From the PR: 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) PR: 248608 Submitted by: Taylor Stearns Changes: _U stable/12/ stable/12/sbin/ipfw/ipfw2.c |
Created attachment 217162 [details] 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