From 22341687ef7e96116b9388b25280736d527660b3 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Thu, 5 Jul 2007 07:28:20 +0000 Subject: [PATCH] Close the group DB even when failing with 2^31 or more members. * lib/getugroups.c (getugroups): Don't return without calling endgrent. --- ChangeLog | 5 +++++ lib/getugroups.c | 10 +++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index ffdb2c23ad..b2bd707fb4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2007-07-05 Jim Meyering + + Close the group DB even when failing with 2^31 or more members. + * lib/getugroups.c (getugroups): Don't return without calling endgrent. + 2007-07-04 Jim Meyering * lib/getugroups.h: New file. diff --git a/lib/getugroups.c b/lib/getugroups.c index 0293d27850..d63a6072e4 100644 --- a/lib/getugroups.c +++ b/lib/getugroups.c @@ -84,21 +84,21 @@ getugroups (int maxcount, GETGROUPS_T *grouplist, char const *username, if (maxcount != 0) { if (count >= maxcount) - { - endgrent (); - return count; - } + goto done; grouplist[count] = grp->gr_gid; } count++; if (count < 0) { errno = EOVERFLOW; - return -1; + count = -1; + goto done; } } } } + + done: endgrent (); return count; -- 2.30.2