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)
Dec 20 2023, 5:38 AM
Unknown Object (File)
Dec 12 2023, 4:20 PM
Unknown Object (File)
Nov 19 2023, 1:44 AM
Unknown Object (File)
Sep 6 2023, 7:35 AM
Unknown Object (File)
Sep 1 2023, 12:40 PM
Unknown Object (File)
Sep 1 2023, 12:39 PM
Unknown Object (File)
Sep 1 2023, 12:35 PM
Unknown Object (File)
Sep 1 2023, 12:29 PM
Subscribers

Details

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

Sponsored by:   The FreeBSD Foundation

Diff Detail

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

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

Why not just printf()?

contrib/pf/authpf/authpf.c
569

Attempting to minimize differences from OpenBSD

contrib/pf/authpf/authpf.c
569

Oh that's fair.