aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Evans <kevans@FreeBSD.org>2025-09-13 22:19:46 +0000
committerKyle Evans <kevans@FreeBSD.org>2025-09-13 22:19:46 +0000
commit91ea7e2ce2b5b2ff4702c3092cfe944862d58172 (patch)
tree90a77cade3ec42b873f0e315396ed219d3a1b5e8
parentdd32d6b29d49838c99d38ba30846ade210b2e6f7 (diff)
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
-rw-r--r--lib/libc/gen/getgrouplist.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/lib/libc/gen/getgrouplist.c b/lib/libc/gen/getgrouplist.c
index cb23b9b2316d..9c57b7031336 100644
--- a/lib/libc/gen/getgrouplist.c
+++ b/lib/libc/gen/getgrouplist.c
@@ -31,6 +31,7 @@
#include <sys/types.h>
+#include <unistd.h>
#include <ssp/ssp.h>
extern int __getgroupmembership(const char *, gid_t, gid_t *, int, int *);