summaryrefslogtreecommitdiff
path: root/lib/getugroups.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2007-07-05 07:28:20 +0000
committerJim Meyering <jim@meyering.net>2007-07-05 07:28:20 +0000
commit22341687ef7e96116b9388b25280736d527660b3 (patch)
treeedf80a975a340ff03f9931239737fdde0b635337 /lib/getugroups.c
parentc471cb38f3b7a9011f58d585dbdb0057e7bbd331 (diff)
downloadgnulib-22341687ef7e96116b9388b25280736d527660b3.tar.gz
Close the group DB even when failing with 2^31 or more members.
* lib/getugroups.c (getugroups): Don't return without calling endgrent.
Diffstat (limited to 'lib/getugroups.c')
-rw-r--r--lib/getugroups.c10
1 files changed, 5 insertions, 5 deletions
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;