From 40bfaaed40ba831cacc3d74b8c2f216249c141ec Mon Sep 17 00:00:00 2001 From: Tomas Mraz Date: Wed, 30 Mar 2005 10:42:54 +0000 Subject: 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 --- modules/pammodutil/modutil_getpwuid.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'modules/pammodutil/modutil_getpwuid.c') diff --git a/modules/pammodutil/modutil_getpwuid.c b/modules/pammodutil/modutil_getpwuid.c index f28ed4e4..602c6b8e 100644 --- a/modules/pammodutil/modutil_getpwuid.c +++ b/modules/pammodutil/modutil_getpwuid.c @@ -71,6 +71,7 @@ struct passwd *_pammodutil_getpwuid(pam_handle_t *pamh, uid_t uid) buffer = new_buffer; /* make the re-entrant call to get the pwd structure */ + errno = 0; status = getpwuid_r(uid, buffer, sizeof(struct passwd) + (char *) buffer, length, &result); @@ -120,9 +121,12 @@ struct passwd *_pammodutil_getpwuid(pam_handle_t *pamh, uid_t uid) 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); -- cgit v1.2.3