Bug 269075 - pfctl and ifconfig invalid if statements
Summary: pfctl and ifconfig invalid if statements
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-01-20 19:29 UTC by Nick Reilly
Modified: 2023-06-05 10:36 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Reilly 2023-01-20 19:29:17 UTC
sbin/ifconfig/ifieee80211.c in printmimo()
	for (i = 0; i < IEEE80211_MAX_CHAINS; i++) {
		if (mi->ch[i].rssi != 0) {
			r = 1;

But rssi is an array so the if statement is always true. Suggested fix is:
	for (i = 0; i < IEEE80211_MAX_CHAINS; i++) {
		if (mi->ch[i].rssi[0] != 0) {
			r = 1;


There are similar issues in sbin/pfctl/pfctl.c in pfctl_show_rules(). There are two instances (lines 1312 and 1366) of:

			if (rule.label[0] && (opts & PF_OPT_SHOWALL))
				labels = 1;

But rule is a two dimensional array so the if statement is always true. Suggested fix is:
			if (rule.label[0][0] && (opts & PF_OPT_SHOWALL))
				labels = 1;
Comment 1 commit-hook freebsd_committer freebsd_triage 2023-01-24 08:37:39 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=cd80c52cade3e38d273eecec6f9b0a7cba23bcc8

commit cd80c52cade3e38d273eecec6f9b0a7cba23bcc8
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2023-01-24 06:46:46 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2023-01-24 06:46:46 +0000

    pfctl: rule.label is a two-dimensional array

    Fix checking for a non-empty first string.

    PR:             269075
    MFC after:      1 week
    Reported by:    nreilly@blackberry.com

 sbin/pfctl/pfctl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Comment 2 commit-hook freebsd_committer freebsd_triage 2023-01-31 09:31:35 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=f8986380049a998e78acf08a19db3c92edc78a88

commit f8986380049a998e78acf08a19db3c92edc78a88
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2023-01-24 06:46:46 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2023-01-31 03:29:47 +0000

    pfctl: rule.label is a two-dimensional array

    Fix checking for a non-empty first string.

    PR:             269075
    MFC after:      1 week
    Reported by:    nreilly@blackberry.com

    (cherry picked from commit cd80c52cade3e38d273eecec6f9b0a7cba23bcc8)

 sbin/pfctl/pfctl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Comment 3 commit-hook freebsd_committer freebsd_triage 2023-01-31 09:46:37 UTC
A commit in branch stable/12 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=5a0cbbcaca6dcb656cb9d7b50de3a81654d02020

commit 5a0cbbcaca6dcb656cb9d7b50de3a81654d02020
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2023-01-24 06:46:46 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2023-01-31 03:29:52 +0000

    pfctl: rule.label is a two-dimensional array

    Fix checking for a non-empty first string.

    PR:             269075
    MFC after:      1 week
    Reported by:    nreilly@blackberry.com

    (cherry picked from commit cd80c52cade3e38d273eecec6f9b0a7cba23bcc8)

 sbin/pfctl/pfctl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)