diff options
author | Tomas Mraz <tm@t8m.info> | 2005-03-30 10:42:54 +0000 |
---|---|---|
committer | Tomas Mraz <tm@t8m.info> | 2005-03-30 10:42:54 +0000 |
commit | 40bfaaed40ba831cacc3d74b8c2f216249c141ec (patch) | |
tree | 272f3a993155caef2283cdeed50d4cb7d72e211b /modules/pammodutil/modutil_getgrnam.c | |
parent | d9d7f8271057e87ca766a91873321e3d9c203984 (diff) | |
download | pam-40bfaaed40ba831cacc3d74b8c2f216249c141ec.tar.gz pam-40bfaaed40ba831cacc3d74b8c2f216249c141ec.tar.bz2 pam-40bfaaed40ba831cacc3d74b8c2f216249c141ec.zip |
Relevant BUGIDs:
Purpose of commit: bugfix
Commit summary:
---------------
Fix wrong allocation in _pammodutil_gr* functions.
Raise the limit on allocated memory size.
Don't retry call if not ERANGE or EINTR
Diffstat (limited to 'modules/pammodutil/modutil_getgrnam.c')
-rw-r--r-- | modules/pammodutil/modutil_getgrnam.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/modules/pammodutil/modutil_getgrnam.c b/modules/pammodutil/modutil_getgrnam.c index 7e2d43ff..3750e75d 100644 --- a/modules/pammodutil/modutil_getgrnam.c +++ b/modules/pammodutil/modutil_getgrnam.c @@ -47,7 +47,7 @@ struct group *_pammodutil_getgrnam(pam_handle_t *pamh, const char *group) void *new_buffer; struct group *result = NULL; - new_buffer = realloc(buffer, sizeof(struct passwd) + length); + new_buffer = realloc(buffer, sizeof(struct group) + length); if (new_buffer == NULL) { D(("out of memory")); @@ -61,6 +61,7 @@ struct group *_pammodutil_getgrnam(pam_handle_t *pamh, const char *group) buffer = new_buffer; /* make the re-entrant call to get the grp structure */ + errno = 0; status = getgrnam_r(group, buffer, sizeof(struct group) + (char *) buffer, length, &result); @@ -109,9 +110,12 @@ struct group *_pammodutil_getgrnam(pam_handle_t *pamh, const char *group) free(buffer); return NULL; - } + } else if (errno != ERANGE && errno != EINTR) { + /* no sense in repeating the call */ + break; + } - length <<= 1; + length <<= 2; } while (length < PWD_ABSURD_PWD_LENGTH); |