1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-31 16:21:26 +03:00

user-util: minor updates of in_gid()

Let's use newa() and use the right type for storing sysconf() return
values.
This commit is contained in:
Lennart Poettering 2017-12-30 14:05:41 +01:00
parent 43f2c88df0
commit 2dc894541f

View File

@ -358,8 +358,9 @@ char* gid_to_name(gid_t gid) {
} }
int in_gid(gid_t gid) { int in_gid(gid_t gid) {
long ngroups_max;
gid_t *gids; gid_t *gids;
int ngroups_max, r, i; int r, i;
if (getgid() == gid) if (getgid() == gid)
return 1; return 1;
@ -373,7 +374,7 @@ int in_gid(gid_t gid) {
ngroups_max = sysconf(_SC_NGROUPS_MAX); ngroups_max = sysconf(_SC_NGROUPS_MAX);
assert(ngroups_max > 0); assert(ngroups_max > 0);
gids = alloca(sizeof(gid_t) * ngroups_max); gids = newa(gid_t, ngroups_max);
r = getgroups(ngroups_max, gids); r = getgroups(ngroups_max, gids);
if (r < 0) if (r < 0)