[linux-pam] Add checks for crypt() returning NULL.
by Tomáš Mráz
commit 8dc056c1c8bc7acb66c4decc49add2c3a24e6310
Author: Tomas Mraz <tmraz(a)fedoraproject.org>
Date: Fri Feb 8 15:04:26 2013 +0100
Add checks for crypt() returning NULL.
modules/pam_pwhistory/opasswd.c (compare_password): Add check for crypt() NULL return.
modules/pam_unix/bigcrypt.c (bigcrypt): Likewise.
modules/pam_pwhistory/opasswd.c | 2 +-
modules/pam_unix/bigcrypt.c | 9 +++++++++
2 files changed, 10 insertions(+), 1 deletions(-)
---
diff --git a/modules/pam_pwhistory/opasswd.c b/modules/pam_pwhistory/opasswd.c
index 274fdb9..836d713 100644
--- a/modules/pam_pwhistory/opasswd.c
+++ b/modules/pam_pwhistory/opasswd.c
@@ -108,7 +108,7 @@ compare_password(const char *newpass, const char *oldpass)
outval = crypt (newpass, oldpass);
#endif
- return strcmp(outval, oldpass) == 0;
+ return outval != NULL && strcmp(outval, oldpass) == 0;
}
/* Check, if the new password is already in the opasswd file. */
diff --git a/modules/pam_unix/bigcrypt.c b/modules/pam_unix/bigcrypt.c
index e10d1c5..e1d57a0 100644
--- a/modules/pam_unix/bigcrypt.c
+++ b/modules/pam_unix/bigcrypt.c
@@ -109,6 +109,10 @@ char *bigcrypt(const char *key, const char *salt)
#else
tmp_ptr = crypt(plaintext_ptr, salt); /* libc crypt() */
#endif
+ if (tmp_ptr == NULL) {
+ free(dec_c2_cryptbuf);
+ return NULL;
+ }
/* and place in the static area */
strncpy(cipher_ptr, tmp_ptr, 13);
cipher_ptr += ESEGMENT_SIZE + SALT_SIZE;
@@ -130,6 +134,11 @@ char *bigcrypt(const char *key, const char *salt)
#else
tmp_ptr = crypt(plaintext_ptr, salt_ptr);
#endif
+ if (tmp_ptr == NULL) {
+ _pam_overwrite(dec_c2_cryptbuf);
+ free(dec_c2_cryptbuf);
+ return NULL;
+ }
/* skip the salt for seg!=0 */
strncpy(cipher_ptr, (tmp_ptr + SALT_SIZE), ESEGMENT_SIZE);
11 years, 2 months
[linux-pam] pam_userdb: Allow also modern password hashes supported by crypt().
by Tomáš Mráz
commit e2a818773f96d12fc9f91bf2792a5a216c3b9aa4
Author: Tomas Mraz <tmraz(a)fedoraproject.org>
Date: Thu Feb 7 17:06:57 2013 +0100
pam_userdb: Allow also modern password hashes supported by crypt().
modules/pam_userdb/pam_userdb.c (user_lookup): Allow password hashes
longer than 13 characters and long salt.
modules/pam_userdb/pam_userdb.c | 8 ++------
1 files changed, 2 insertions(+), 6 deletions(-)
---
diff --git a/modules/pam_userdb/pam_userdb.c b/modules/pam_userdb/pam_userdb.c
index c075c4b..de8b5b1 100644
--- a/modules/pam_userdb/pam_userdb.c
+++ b/modules/pam_userdb/pam_userdb.c
@@ -214,17 +214,13 @@ user_lookup (pam_handle_t *pamh, const char *database, const char *cryptmode,
/* crypt(3) password storage */
char *cryptpw;
- char salt[2];
- if (data.dsize != 13) {
+ if (data.dsize < 13) {
compare = -2;
} else if (ctrl & PAM_ICASE_ARG) {
compare = -2;
} else {
- salt[0] = *data.dptr;
- salt[1] = *(data.dptr + 1);
-
- cryptpw = crypt (pass, salt);
+ cryptpw = crypt (pass, data.dptr);
if (cryptpw) {
compare = strncasecmp (data.dptr, cryptpw, data.dsize);
11 years, 2 months