]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
2005-03-29 Thorsten Kukuk <kukuk@suse.de>
authorRoland McGrath <roland@gnu.org>
Tue, 29 Mar 2005 23:40:49 +0000 (23:40 +0000)
committerRoland McGrath <roland@gnu.org>
Tue, 29 Mar 2005 23:40:49 +0000 (23:40 +0000)
[BZ #661]
* grp/initgroups.c (internal_getgrouplist): Check if we have
enough space before adding the primary group to the list.

grp/initgroups.c

index d052cf48f7b9bdd4861c7f89e744785bf1bb42a5..b887a973ff611502797d66d21306618db8f3712f 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1989,91,93,1996-2003, 2004  Free Software Foundation, Inc.
+/* Copyright (C) 1989,91,93,1996-2003, 2004, 2005  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
@@ -73,7 +73,9 @@ internal_getgrouplist (const char *user, gid_t group, long int *size,
   /* Start is one, because we have the first group as parameter.  */
   long int start = 1;
 
-  (*groupsp)[0] = group;
+  /* Never store more than the starting *SIZE number of elements.  */
+  if (*size > 0)
+    (*groupsp)[0] = group;
 
   if (__nss_group_database != NULL)
     {