aboutsummaryrefslogtreecommitdiff
path: root/grp
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2003-04-23 21:27:36 +0000
committerUlrich Drepper <drepper@redhat.com>2003-04-23 21:27:36 +0000
commitb9b9a51e4911b17e75b39fd3db9f7268e233ce20 (patch)
tree95c02630a80ee0b0c094bdde7594401d350cf58e /grp
parent370b4d44dc9f8c29f842d1799cc096825bcc1ed7 (diff)
downloadglibc-b9b9a51e4911b17e75b39fd3db9f7268e233ce20.tar
glibc-b9b9a51e4911b17e75b39fd3db9f7268e233ce20.tar.gz
glibc-b9b9a51e4911b17e75b39fd3db9f7268e233ce20.tar.bz2
glibc-b9b9a51e4911b17e75b39fd3db9f7268e233ce20.zip
Update.
2003-04-23 Ulrich Drepper <drepper@redhat.com> * grp/initgroups.c (getgrouplist): Don't copy too much into the user buffer if more groups are found than fit into it. * nis/nss_nis/nis-initgroups.c (_nss_nis_initgroups_dyn): Use extend_alloca.
Diffstat (limited to 'grp')
-rw-r--r--grp/initgroups.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/grp/initgroups.c b/grp/initgroups.c
index dd7a8fde1c..1e4c2b5c2b 100644
--- a/grp/initgroups.c
+++ b/grp/initgroups.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1989,91,93,1996-2001, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1989,91,93,1996-2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -23,6 +23,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <sys/param.h>
#include <sys/types.h>
#include <nsswitch.h>
@@ -207,6 +208,9 @@ getgrouplist (const char *user, gid_t group, gid_t *groups, int *ngroups)
return -1;
result = internal_getgrouplist (user, group, &size, &newgroups, -1);
+
+ memcpy (groups, newgroups, MIN (*ngroups, result) * sizeof (gid_t));
+
if (result > *ngroups)
{
*ngroups = result;
@@ -215,8 +219,6 @@ getgrouplist (const char *user, gid_t group, gid_t *groups, int *ngroups)
else
*ngroups = result;
- memcpy (groups, newgroups, *ngroups * sizeof (gid_t));
-
free (newgroups);
return result;
}