Page MenuHomeFreeBSD

pfctl: Fix superblock printf format mismatch
ClosedPublic

Authored by vegeta_tuxpowered.net on Mar 5 2023, 8:37 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Nov 9, 2:54 AM
Unknown Object (File)
Oct 16 2024, 1:12 AM
Unknown Object (File)
Oct 16 2024, 12:50 AM
Unknown Object (File)
Sep 15 2024, 9:05 PM
Unknown Object (File)
Sep 11 2024, 6:34 AM
Unknown Object (File)
Sep 9 2024, 10:49 PM
Unknown Object (File)
Sep 8 2024, 7:35 PM
Unknown Object (File)
Sep 8 2024, 3:46 AM
Subscribers

Details

Summary

It is impossible to compile pfctl with OPT_DEBUG due to integer width mismatch:

/usr/home/kajetan.staszkiewicz/freebsd.git/sbin/pfctl/pfctl_optimize.c:1479:9: error: format specifies type 'unsigned int' but the argument has type 'unsigned long' [-Werror,-Wformat]
                                    i - pf_rule_desc[closest].prf_off--- pfctl_optimize.o ---
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/home/kajetan.staszkiewicz/freebsd.git/sbin/pfctl/pfctl_optimize.c:52:44: note: expanded from macro 'DEBUG'
        printf("%s: " str "\n", __FUNCTION__ , ## v)
                      ~~~                         ^
1 error generated.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

ok, in this case commit message should reference openbsd, like so: "Obtained from: OpenBSD (pfctl_optimize.c 1.15)"

With the patch that seems to fail to build on armv6 (and I suspect on i386 as well):

/usr/src/sbin/pfctl/pfctl_optimize.c:1482:9: error: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Werror,-Wformat]
                                    i - pf_rule_desc[closest].prf_off^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/src/sbin/pfctl/pfctl_optimize.c:52:44: note: expanded from macro 'DEBUG'
        printf("%s: " str "\n", __FUNCTION__ , ## v)
                      ~~~                         ^
1 error generated.
*** [pfctl_optimize.o] Error code 1

I believe we want %zxh, because 'z' is specifically intended to print size_t, whereas 'l' implies an unsigned long, which isn't always what size_t is.
I've kicked off another make universe with z rather than l.

This revision was not accepted when it landed; it landed in state Needs Review.Mar 6 2023, 7:27 PM
This revision was automatically updated to reflect the committed changes.