[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
lib/getugroups overflow check
From: |
Paul Eggert |
Subject: |
lib/getugroups overflow check |
Date: |
Wed, 28 Jul 2004 12:42:09 -0700 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) |
I installed this patch for a very unlikely problem: more than INT_MAX groups.
2004-07-28 Paul Eggert <address@hidden>
* getugroups.c: Include <errno.h>.
(EOVERFLOW): Define if not defined.
(getgroups): Return -1 with errno=EOVERFLOW if an integer overflow
occurs.
Index: getugroups.c
===================================================================
RCS file: /home/eggert/coreutils/cu/lib/getugroups.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -p -u -r1.12 -r1.13
--- getugroups.c 10 Sep 2003 08:45:43 -0000 1.12
+++ getugroups.c 28 Jul 2004 19:41:08 -0000 1.13
@@ -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 @@ getugroups (int maxcount, GETGROUPS_T *g
grouplist[count] = grp->gr_gid;
}
count++;
+ if (count < 0)
+ {
+ errno = EOVERFLOW;
+ return -1;
+ }
}
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- lib/getugroups overflow check,
Paul Eggert <=