From 5d398d514940ad9301e36126a62b206cf6728bbf Mon Sep 17 00:00:00 2001 From: Steve Langasek Date: Fri, 30 Sep 2005 09:09:51 +0000 Subject: [PATCH] Relevant BUGIDs: none Purpose of commit: bugfix Commit summary: --------------- Fix memory leak due to gratuitous use of strdup(). --- ChangeLog | 5 +++++ modules/pam_userdb/pam_userdb.c | 14 +++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index e5cda09d..20850d4d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2005-09-30 Steve Langasek + + * modules/pam_userdb/pam_userdb.c: Fix memory leak due to + gratuitous use of strdup(). + 2005-09-27 Thorsten Kukuk * release 0.99.1.0 diff --git a/modules/pam_userdb/pam_userdb.c b/modules/pam_userdb/pam_userdb.c index f584a438..662c7ac3 100644 --- a/modules/pam_userdb/pam_userdb.c +++ b/modules/pam_userdb/pam_userdb.c @@ -113,14 +113,14 @@ _pam_parse (pam_handle_t *pamh, int argc, const char **argv, ctrl |= PAM_TRY_FPASS_ARG; else if (!strncasecmp(*argv,"db=", 3)) { - *database = strdup((*argv) + 3); + *database = (*argv) + 3; if ((*database == NULL) || (strlen (*database) == 0)) pam_syslog(pamh, LOG_ERR, "could not parse argument \"%s\"", *argv); } else if (!strncasecmp(*argv,"crypt=", 6)) { - *cryptmode = strdup((*argv) + 6); + *cryptmode = (*argv) + 6; if ((*cryptmode == NULL) || (strlen (*cryptmode) == 0)) pam_syslog(pamh, LOG_ERR, "could not parse argument \"%s\"", *argv); @@ -239,13 +239,13 @@ user_lookup (pam_handle_t *pamh, const char *database, const char *cryptmode, * default to plaintext password storage */ - if (strlen(pass) != (size_t)data.dsize) { - compare = 1; /* wrong password len -> wrong password */ - } else if (ctrl & PAM_ICASE_ARG) { + if (strlen(pass) != (size_t)data.dsize) { + compare = 1; /* wrong password len -> wrong password */ + } else if (ctrl & PAM_ICASE_ARG) { compare = strncasecmp(data.dptr, pass, data.dsize); - } else { + } else { compare = strncmp(data.dptr, pass, data.dsize); - } + } if (cryptmode && strncasecmp(cryptmode, "none", 4) && (ctrl & PAM_DEBUG_ARG)) { -- 2.40.0