summaryrefslogtreecommitdiff
path: root/modules/pammodutil
diff options
context:
space:
mode:
authorTomas Mraz <tm@t8m.info>2005-03-30 10:42:54 +0000
committerTomas Mraz <tm@t8m.info>2005-03-30 10:42:54 +0000
commit40bfaaed40ba831cacc3d74b8c2f216249c141ec (patch)
tree272f3a993155caef2283cdeed50d4cb7d72e211b /modules/pammodutil
parentd9d7f8271057e87ca766a91873321e3d9c203984 (diff)
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')
-rw-r--r--modules/pammodutil/modutil_getgrgid.c8
-rw-r--r--modules/pammodutil/modutil_getgrnam.c10
-rw-r--r--modules/pammodutil/modutil_getpwnam.c8
-rw-r--r--modules/pammodutil/modutil_getpwuid.c8
-rw-r--r--modules/pammodutil/modutil_getspnam.c8
-rw-r--r--modules/pammodutil/pammodutil.h2
6 files changed, 32 insertions, 12 deletions
diff --git a/modules/pammodutil/modutil_getgrgid.c b/modules/pammodutil/modutil_getgrgid.c
index dcac4f78..4520ff55 100644
--- a/modules/pammodutil/modutil_getgrgid.c
+++ b/modules/pammodutil/modutil_getgrgid.c
@@ -57,7 +57,7 @@ struct group *_pammodutil_getgrgid(pam_handle_t *pamh, gid_t gid)
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"));
@@ -71,6 +71,7 @@ struct group *_pammodutil_getgrgid(pam_handle_t *pamh, gid_t gid)
buffer = new_buffer;
/* make the re-entrant call to get the grp structure */
+ errno = 0;
status = getgrgid_r(gid, buffer,
sizeof(struct group) + (char *) buffer,
length, &result);
@@ -120,9 +121,12 @@ struct group *_pammodutil_getgrgid(pam_handle_t *pamh, gid_t gid)
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);
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);
diff --git a/modules/pammodutil/modutil_getpwnam.c b/modules/pammodutil/modutil_getpwnam.c
index 891b0b58..ecef0303 100644
--- a/modules/pammodutil/modutil_getpwnam.c
+++ b/modules/pammodutil/modutil_getpwnam.c
@@ -61,6 +61,7 @@ struct passwd *_pammodutil_getpwnam(pam_handle_t *pamh, const char *user)
buffer = new_buffer;
/* make the re-entrant call to get the pwd structure */
+ errno = 0;
status = getpwnam_r(user, buffer,
sizeof(struct passwd) + (char *) buffer,
length, &result);
@@ -109,9 +110,12 @@ struct passwd *_pammodutil_getpwnam(pam_handle_t *pamh, const char *user)
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);
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);
diff --git a/modules/pammodutil/modutil_getspnam.c b/modules/pammodutil/modutil_getspnam.c
index 325cfd33..72fa29ee 100644
--- a/modules/pammodutil/modutil_getspnam.c
+++ b/modules/pammodutil/modutil_getspnam.c
@@ -61,6 +61,7 @@ struct spwd *_pammodutil_getspnam(pam_handle_t *pamh, const char *user)
buffer = new_buffer;
/* make the re-entrant call to get the spwd structure */
+ errno = 0;
status = getspnam_r(user, buffer,
sizeof(struct spwd) + (char *) buffer,
length, &result);
@@ -109,9 +110,12 @@ struct spwd *_pammodutil_getspnam(pam_handle_t *pamh, const char *user)
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);
diff --git a/modules/pammodutil/pammodutil.h b/modules/pammodutil/pammodutil.h
index efcc98e1..fbe81023 100644
--- a/modules/pammodutil/pammodutil.h
+++ b/modules/pammodutil/pammodutil.h
@@ -13,7 +13,7 @@
#include <security/_pam_modutil.h>
#define PWD_INITIAL_LENGTH 0x100
-#define PWD_ABSURD_PWD_LENGTH 0x1000
+#define PWD_ABSURD_PWD_LENGTH 0x8000
/* This is a simple cleanup, it just free()s the 'data' memory */
extern void _pammodutil_cleanup(pam_handle_t *pamh, void *data,