From 5df6537480e6da41d19bf11013df3639843539be Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sat, 30 Dec 2017 14:05:41 +0100 Subject: [PATCH] user-util: minor updates of in_gid() Let's use newa() and use the right type for storing sysconf() return values. --- src/basic/user-util.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/basic/user-util.c b/src/basic/user-util.c index ee42b10cb..3f364b3b3 100644 --- a/src/basic/user-util.c +++ b/src/basic/user-util.c @@ -363,8 +363,9 @@ char* gid_to_name(gid_t gid) { #if 0 /// UNNEEDED by elogind int in_gid(gid_t gid) { + long ngroups_max; gid_t *gids; - int ngroups_max, r, i; + int r, i; if (getgid() == gid) return 1; @@ -378,7 +379,7 @@ int in_gid(gid_t gid) { ngroups_max = sysconf(_SC_NGROUPS_MAX); assert(ngroups_max > 0); - gids = alloca(sizeof(gid_t) * ngroups_max); + gids = newa(gid_t, ngroups_max); r = getgroups(ngroups_max, gids); if (r < 0) -- 2.30.2