diff options
author | djl <none@none> | 2008-03-25 10:48:32 -0700 |
---|---|---|
committer | djl <none@none> | 2008-03-25 10:48:32 -0700 |
commit | 6dd841390b98241b22857b3e09e7720492884621 (patch) | |
tree | be6f8ab1236c4a9768790c5c1a319b60bdbb9bda /usr/src/lib/nsswitch/files/common/files_common.c | |
parent | 80252d54f78e0c9d6807f9faa20fb7bd5cdc6956 (diff) | |
download | illumos-joyent-6dd841390b98241b22857b3e09e7720492884621.tar.gz |
6564720 Large groups bug still in this release
6662929 getusernam(3secdb) and friends return null when the selected /etc/user_attr line is > 1024
Diffstat (limited to 'usr/src/lib/nsswitch/files/common/files_common.c')
-rw-r--r-- | usr/src/lib/nsswitch/files/common/files_common.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/usr/src/lib/nsswitch/files/common/files_common.c b/usr/src/lib/nsswitch/files/common/files_common.c index 0f89f25d0b..74d47f7c8c 100644 --- a/usr/src/lib/nsswitch/files/common/files_common.c +++ b/usr/src/lib/nsswitch/files/common/files_common.c @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. * * Common code and structures used by name-service-switch "files" backends. @@ -150,13 +150,16 @@ _nss_files_do_all(be, args, filter, func) const char *filter; files_do_all_func_t func; { + long grlen; char *buffer; int buflen; nss_status_t res; - if (be->buf == 0 && - (be->buf = malloc(be->minbuf)) == 0) { - return (NSS_UNAVAIL); + if (be->buf == 0) { + if ((grlen = sysconf(_SC_GETGR_R_SIZE_MAX)) > 0) + be->minbuf = grlen; + if ((be->buf = malloc(be->minbuf)) == 0) + return (NSS_UNAVAIL); } buffer = be->buf; buflen = be->minbuf; @@ -205,15 +208,26 @@ _nss_files_XY_all(be, args, netdb, filter, check) /* string search */ files_XY_check_func check; /* NULL means one-shot, for getXXent */ { + char *r; nss_status_t res; int parsestat; int (*func)(); if (filter != NULL && *filter == '\0') return (NSS_NOTFOUND); - if (be->buf == 0 && - (be->buf = malloc(be->minbuf)) == 0) { - return (NSS_UNAVAIL); /* really panic, malloc failed */ + if (be->buf == 0 || (be->minbuf < args->buf.buflen)) { + if (be->minbuf < args->buf.buflen) { + if (be->buf == 0) { + be->minbuf = args->buf.buflen; + } else if ( + (r = realloc(be->buf, args->buf.buflen)) != NULL) { + be->buf = r; + be->minbuf = args->buf.buflen; + } + } + if (be->buf == 0 && + (be->buf = malloc(be->minbuf)) == 0) + return (NSS_UNAVAIL); } if (check != 0 || be->f == 0) { @@ -670,7 +684,7 @@ _nss_files_check_name_aliases(nss_XbyY_args_t *argp, const char *line, /* compare with the alias name */ keyp = argp->key.name; while (*keyp && linep < limit && !isspace(*linep) && - *keyp == *linep) { + *keyp == *linep) { keyp++; linep++; } |