diff options
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 */ |