From 2b5457bbf7352200f7bc77795adbbcfd47550855 Mon Sep 17 00:00:00 2001 From: Tomas Mraz Date: Thu, 28 Jul 2005 10:16:55 +0000 Subject: Relevant BUGIDs: Red Hat bz #164418 Purpose of commit: bugfix Commit summary: --------------- pam_userdb: Fix regression - crash when crypt param not specified --- modules/pam_userdb/pam_userdb.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'modules/pam_userdb/pam_userdb.c') diff --git a/modules/pam_userdb/pam_userdb.c b/modules/pam_userdb/pam_userdb.c index 09467877..87a6ffd5 100644 --- a/modules/pam_userdb/pam_userdb.c +++ b/modules/pam_userdb/pam_userdb.c @@ -164,8 +164,8 @@ user_lookup (const char *database, const char *cryptmode, } if (ctrl & PAM_DEBUG_ARG) { - _pam_log(LOG_INFO, "password in database is [%p]`%s', len is %d", - data.dptr, (char *) data.dptr, data.dsize); + _pam_log(LOG_INFO, "password in database is [%p]`%.*s', len is %d", + data.dptr, data.dsize, (char *) data.dptr, data.dsize); } if (data.dptr != NULL) { @@ -177,7 +177,7 @@ user_lookup (const char *database, const char *cryptmode, return 0; /* found it, data contents don't matter */ } - if (strncasecmp(cryptmode, "crypt", 5) == 0) { + if (cryptmode && strncasecmp(cryptmode, "crypt", 5) == 0) { /* crypt(3) password storage */ @@ -219,7 +219,8 @@ user_lookup (const char *database, const char *cryptmode, compare = strncmp(data.dptr, pass, data.dsize); } - if (strncasecmp(cryptmode, "none", 4) && ctrl & PAM_DEBUG_ARG) { + if (cryptmode && strncasecmp(cryptmode, "none", 4) + && (ctrl & PAM_DEBUG_ARG)) { _pam_log(LOG_INFO, "invalid value for crypt parameter: %s", cryptmode); _pam_log(LOG_INFO, "defaulting to plaintext password mode"); -- cgit v1.2.3