HomeFreeBSD

libc: fix the _FORTIFY_SOURCE build of getgrouplist(3)

Description

libc: fix the _FORTIFY_SOURCE build of getgrouplist(3)

We need <unistd.h> to get our prototype normally, but WARNS in libc is
way too low to surface that.

Additionally, _FORTIFY_SOURCE needs to include <ssp/unistd.h> by way of
<unistd.h> to actually export an implementation of getgrouplist(3). The
version defined in the .c gets named ssp_real_getgrouplist() and the
actual implementation comes from the redirect stub in <ssp/unistd.h>,
which basically gets optimized away in the built object because our
builtin_object_size() check is trivially false when we cannot resolve
any object sizes in this translation unit.

This could be argued as a design flaw in _FORTIFY_SOURCE, but we should
grab <unistd.h> for our prototype anyways so let's kick the can down
the road instead of re-thinking it for 15.0.

Reported by: Shawn Webb (HardenedBSD)
Fixes: d3f8ed6066 ("getgrouplist(3): Remove superfluous [...]")
MFC after: 3 days

Details

Provenance
kevansAuthored on Sep 13 2025, 10:19 PM
Parents
rGdd32d6b29d49: zfs: merge openzfs/zfs@3f4312a0a
Branches
Unknown
Tags
Unknown