summaryrefslogtreecommitdiff
path: root/hesiod
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2000-07-24 05:41:25 +0000
committerUlrich Drepper <drepper@redhat.com>2000-07-24 05:41:25 +0000
commit7603ea28d333d47f8e45e33515362ec55d381877 (patch)
treebea0b39db5db660696f86369635be85811b0d165 /hesiod
parentUpdate. (diff)
downloadglibc-7603ea28d333d47f8e45e33515362ec55d381877.tar.gz
glibc-7603ea28d333d47f8e45e33515362ec55d381877.tar.bz2
glibc-7603ea28d333d47f8e45e33515362ec55d381877.zip
Update.
* string/endian.h: Explain the _*_ENDIAN constant values a bit more. Patch by scarlet@mit.edu [PR libc/1799]. * io/ftwtest-sh: Add -f parameter to chmod if -R is also given. [PR libc/1792]. * argp/argp-parse.c (parser_finalize): Reverse order in which parsers are run for ARGP_KEY_END. [PR libc/1755].
Diffstat (limited to 'hesiod')
-rw-r--r--hesiod/nss_hesiod/hesiod-grp.c34
1 files changed, 29 insertions, 5 deletions
diff --git a/hesiod/nss_hesiod/hesiod-grp.c b/hesiod/nss_hesiod/hesiod-grp.c
index a89ed4edaf..5551d7d012 100644
--- a/hesiod/nss_hesiod/hesiod-grp.c
+++ b/hesiod/nss_hesiod/hesiod-grp.c
@@ -25,6 +25,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/param.h>
#include "nss_hesiod.h"
@@ -165,7 +166,8 @@ internal_gid_from_group (void *context, const char *groupname, gid_t *group)
enum nss_status
_nss_hesiod_initgroups_dyn (const char *user, gid_t group, long int *start,
- long int *size, gid_t **groupsp, int *errnop)
+ long int *size, gid_t **groupsp, long int limit,
+ int *errnop)
{
enum nss_status status = NSS_STATUS_SUCCESS;
char **list = NULL;
@@ -191,11 +193,22 @@ _nss_hesiod_initgroups_dyn (const char *user, gid_t group, long int *start,
{
/* Need a bigger buffer. */
gid_t *newgroups;
- newgroups = realloc (groups, 2 * *size * sizeof (*groups));
+ long int newsize;
+
+ if (limit > 0 && *size == limit)
+ /* We reached the maximum. */
+ goto done;
+
+ if (limit <= 0)
+ newsize = 2 * *size;
+ else
+ newsize = MIN (limit, 2 * *size);
+
+ newgroups = realloc (groups, newsize * sizeof (*groups));
if (newgroups == NULL)
goto done;
*groupsp = groups = newgroups;
- *size *= 2;
+ *size = newsize;
}
groups[(*start)++] = group;
@@ -232,11 +245,22 @@ _nss_hesiod_initgroups_dyn (const char *user, gid_t group, long int *start,
{
/* Need a bigger buffer. */
gid_t *newgroups;
- newgroups = realloc (groups, 2 * *size * sizeof (*groups));
+ long int newsize;
+
+ if (limit > 0 && *size == limit)
+ /* We reached the maximum. */
+ goto done;
+
+ if (limit <= 0)
+ newsize = 2 * *size;
+ else
+ newsize = MIN (limit, 2 * *size);
+
+ newgroups = realloc (groups, newsize * sizeof (*groups));
if (newgroups == NULL)
goto done;
*groupsp = groups = newgroups;
- *size *= 2;
+ *size = newsize;
}
groups[(*start)++] = group;