From: Jim Meyering Date: Thu, 16 Oct 2003 08:23:41 +0000 (+0000) Subject: Include , . X-Git-Tag: v5.1.0~369 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5b18a21b2db5304e2a13e5805471dd92f6effbdc;p=thirdparty%2Fcoreutils.git Include , . (getgroups): First arg is int, not size_t. Don't let 'free' mangle errno. --- diff --git a/lib/getgroups.c b/lib/getgroups.c index f6808b3333..e27cadc3e9 100644 --- a/lib/getgroups.c +++ b/lib/getgroups.c @@ -20,6 +20,8 @@ #include #include #include +#include +#include #include "xalloc.h" @@ -29,10 +31,11 @@ provided function handle all others. */ int -getgroups (size_t n, GETGROUPS_T *group) +getgroups (int n, GETGROUPS_T *group) { int n_groups; GETGROUPS_T *gbuf; + int saved_errno; #undef getgroups @@ -43,6 +46,9 @@ getgroups (size_t n, GETGROUPS_T *group) gbuf = NULL; while (1) { + /* No need to worry about address arithmetic overflow here, + since the ancient systems that we're running on have low + limits on the number of secondary groups. */ gbuf = xrealloc (gbuf, n * sizeof (GETGROUPS_T)); n_groups = getgroups (n, gbuf); if (n_groups < n) @@ -50,7 +56,9 @@ getgroups (size_t n, GETGROUPS_T *group) n += 10; } + saved_errno = errno; free (gbuf); + errno = saved_errno; return n_groups; }