Page MenuHomeFreeBSD

authpf: do not sprintf to a null pointer
ClosedPublic

Authored by emaste on May 3 2023, 1:31 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Dec 13, 9:13 AM
Unknown Object (File)
Oct 29 2024, 2:11 PM
Unknown Object (File)
Oct 20 2024, 11:56 PM
Unknown Object (File)
Sep 9 2024, 1:48 PM
Unknown Object (File)
Sep 9 2024, 1:48 PM
Unknown Object (File)
Aug 9 2024, 1:52 AM
Unknown Object (File)
Aug 5 2024, 10:29 PM
Unknown Object (File)
Jul 29 2024, 5:46 PM
Subscribers

Details

Summary
The fgetln loop will terminate with buf = NULL at EOF.

Sponsored by:   The FreeBSD Foundation

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

emaste requested review of this revision.May 3 2023, 1:31 PM
emaste created this revision.
/tmp/cirrus-ci-build/contrib/pf/authpf/authpf.c:570:17: warning: argument 1 null where non-null expected [-Wnonnull]
  570 |                 sprintf(buf, "%s", "\n\nSorry, you are not allowed to use this facility!\n");
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /tmp/cirrus-ci-build/sys/sys/nv.h:44,
                 from /tmp/cirrus-ci-build/sys/net/pfvar.h:44,
                 from /tmp/cirrus-ci-build/contrib/pf/authpf/authpf.c:31:
/usr/obj/tmp/cirrus-ci-build/amd64.amd64/tmp/usr/include/stdio.h:286:10: note: in a call to function 'sprintf' declared 'nonnull'
  286 | int      sprintf(char * __restrict, const char * __restrict, ...);
      |          ^~~~~~~
This revision is now accepted and ready to land.May 3 2023, 1:34 PM
This revision was automatically updated to reflect the committed changes.
jhb added inline comments.
contrib/pf/authpf/authpf.c
569

Reusing the buf here was horrible on several reasons.

569–570

Why not just printf()?

contrib/pf/authpf/authpf.c
569–570

Attempting to minimize differences from OpenBSD

contrib/pf/authpf/authpf.c
569–570

Oh that's fair.