diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-26 16:18:37 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-26 16:18:37 +0000 |
commit | b6b00dd55e035bfbe311a527b567962ffa77ee43 (patch) | |
tree | cafc4d13785448e5a78bd40a51697ee07f07ac12 /lib/addgrps.c | |
parent | Adding debian version 1:4.13+dfsg1-5. (diff) | |
download | shadow-b6b00dd55e035bfbe311a527b567962ffa77ee43.tar.xz shadow-b6b00dd55e035bfbe311a527b567962ffa77ee43.zip |
Merging upstream version 1:4.15.2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | lib/addgrps.c (renamed from libmisc/addgrps.c) | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/libmisc/addgrps.c b/lib/addgrps.c index 845d383..dae3dba 100644 --- a/libmisc/addgrps.c +++ b/lib/addgrps.c @@ -17,6 +17,8 @@ #include <stdio.h> #include <grp.h> #include <errno.h> + +#include "alloc.h" #include "shadowlog.h" #ident "$Id$" @@ -29,7 +31,7 @@ */ int add_groups (const char *list) { - GETGROUPS_T *grouplist, *tmp; + GETGROUPS_T *grouplist; size_t i; int ngroups; bool added; @@ -46,7 +48,7 @@ int add_groups (const char *list) i = 16; for (;;) { - grouplist = (gid_t *) malloc (i * sizeof (GETGROUPS_T)); + grouplist = MALLOC(i, GETGROUPS_T); if (NULL == grouplist) { return -1; } @@ -88,19 +90,17 @@ int add_groups (const char *list) fputs (_("Warning: too many groups\n"), shadow_logfd); break; } - tmp = (gid_t *) realloc (grouplist, (size_t)(ngroups + 1) * sizeof (GETGROUPS_T)); - if (NULL == tmp) { - free (grouplist); + grouplist = REALLOCF(grouplist, (size_t) ngroups + 1, GETGROUPS_T); + if (grouplist == NULL) { return -1; } - tmp[ngroups] = grp->gr_gid; + grouplist[ngroups] = grp->gr_gid; ngroups++; - grouplist = tmp; added = true; } if (added) { - ret = setgroups ((size_t)ngroups, grouplist); + ret = setgroups (ngroups, grouplist); free (grouplist); return ret; } @@ -109,6 +109,6 @@ int add_groups (const char *list) return 0; } #else /* HAVE_SETGROUPS && !USE_PAM */ -extern int errno; /* warning: ANSI C forbids an empty source file */ +extern int ISO_C_forbids_an_empty_translation_unit; #endif /* HAVE_SETGROUPS && !USE_PAM */ |