From 9801f8fdc051f8ea469d7ed8c06ccbf7a6a27cc9 Mon Sep 17 00:00:00 2001 From: Tomas Mraz Date: Sat, 17 Sep 2005 08:47:39 +0000 Subject: [PATCH] Relevant BUGIDs: Purpose of commit: cleanup Commit summary: --------------- Better check the input parameters of pam_start (by ldv) --- libpam/pam_start.c | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/libpam/pam_start.c b/libpam/pam_start.c index bf7c9af9..63f58f5b 100644 --- a/libpam/pam_start.c +++ b/libpam/pam_start.c @@ -27,7 +27,19 @@ int pam_start ( if (pamh == NULL) { pam_syslog(NULL, LOG_CRIT, "pam_start: invalid argument: pamh == NULL"); - return (PAM_BUF_ERR); + return (PAM_SYSTEM_ERR); + } + + if (service_name == NULL) { + pam_syslog(NULL, LOG_CRIT, + "pam_start: invalid argument: service == NULL"); + return (PAM_SYSTEM_ERR); + } + + if (pam_conversation == NULL) { + pam_syslog(NULL, LOG_CRIT, + "pam_start: invalid argument: conv == NULL"); + return (PAM_SYSTEM_ERR); } if ((*pamh = calloc(1, sizeof(**pamh))) == NULL) { @@ -45,19 +57,17 @@ int pam_start ( __PAM_TO_APP(*pamh); - if (service_name) { + if (((*pamh)->service_name = _pam_strdup(service_name)) == NULL) { + pam_syslog(*pamh, LOG_CRIT, + "pam_start: _pam_strdup failed for service name"); + _pam_drop(*pamh); + return (PAM_BUF_ERR); + } else { char *tmp; - if (((*pamh)->service_name = _pam_strdup(service_name)) == NULL) { - pam_syslog(*pamh, LOG_CRIT, - "pam_start: _pam_strdup failed for service name"); - _pam_drop(*pamh); - return (PAM_BUF_ERR); - } for (tmp=(*pamh)->service_name; *tmp; ++tmp) *tmp = tolower(*tmp); /* require lower case */ - } else - (*pamh)->service_name = NULL; + } if (user) { if (((*pamh)->user = _pam_strdup(user)) == NULL) { @@ -79,9 +89,8 @@ int pam_start ( (*pamh)->fail_delay.delay_fn_ptr = NULL; (*pamh)->former.choice = PAM_NOT_STACKED; - if (pam_conversation == NULL - || ((*pamh)->pam_conversation = (struct pam_conv *) - malloc(sizeof(struct pam_conv))) == NULL) { + if (((*pamh)->pam_conversation = (struct pam_conv *) + malloc(sizeof(struct pam_conv))) == NULL) { pam_syslog(*pamh, LOG_CRIT, "pam_start: malloc failed for pam_conv"); _pam_drop((*pamh)->service_name); _pam_drop((*pamh)->user); -- 2.40.0