diff lib/getugroups.c @ 5159:a535859efd14

Merge from coreutils.
author Paul Eggert <eggert@cs.ucla.edu>
date Sat, 07 Aug 2004 00:09:38 +0000 (2004-08-07)
parents a4086e076f77
children a48fb0e98c8c
line wrap: on
line diff
--- a/lib/getugroups.c
+++ b/lib/getugroups.c
@@ -1,5 +1,7 @@
 /* getugroups.c -- return a list of the groups a user is in
-   Copyright (C) 1990, 1991, 1998, 1999, 2000, 2003 Free Software Foundation.
+
+   Copyright (C) 1990, 1991, 1998, 1999, 2000, 2003, 2004 Free
+   Software Foundation.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -29,6 +31,11 @@
 # include <unistd.h>
 #endif
 
+#include <errno.h>
+#ifndef EOVERFLOW
+# define EOVERFLOW EINVAL
+#endif
+
 /* setgrent, getgrent, and endgrent are not specified by POSIX.1,
    so header files might not declare them.
    If you don't have them at all, we can't implement this function.
@@ -88,6 +95,11 @@
 		  grouplist[count] = grp->gr_gid;
 		}
 	      count++;
+	      if (count < 0)
+		{
+		  errno = EOVERFLOW;
+		  return -1;
+		}
 	    }
 	}
     }