From 6681d11fd3464c7ba9a74e7f594dcbd3eb96688a Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Mon, 16 Jun 2014 09:12:29 +0000 Subject: [PATCH] * grp.cc (getgrouplist): Fix setting ngroups to make sure to return the right value. --- winsup/cygwin/ChangeLog | 5 +++++ winsup/cygwin/grp.cc | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index a08fb7110..0955ce1a0 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2014-06-16 Denis Excoffier + + * grp.cc (getgrouplist): Fix setting ngroups to make sure to return + the right value. + 2014-06-05 Christopher Faylor * timer.cc (timer_tracker::cancel): Demote api_fatal to system_printf, diff --git a/winsup/cygwin/grp.cc b/winsup/cygwin/grp.cc index 43cae6dc4..f7ce61b08 100644 --- a/winsup/cygwin/grp.cc +++ b/winsup/cygwin/grp.cc @@ -656,11 +656,11 @@ getgrouplist (const char *user, gid_t gid, gid_t *groups, int *ngroups) groups[cnt] = grp->gr_gid; ++cnt; } - *ngroups = cnt; if (cnt > *ngroups) ret = -1; else ret = cnt; + *ngroups = cnt; syscall_printf ( "%d = getgrouplist(%s, %u, %p, %d)", ret, user, gid, groups, *ngroups);