[Bug 269075] pfctl and ifconfig invalid if statements

From: <bugzilla-noreply_at_freebsd.org>
Date: Fri, 20 Jan 2023 19:29:17 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=269075

            Bug ID: 269075
           Summary: pfctl and ifconfig invalid if statements
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: nreilly@blackberry.com

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;

-- 
You are receiving this mail because:
You are the assignee for the bug.