summaryrefslogtreecommitdiff
path: root/libpam
diff options
context:
space:
mode:
authorTomas Mraz <tm@t8m.info>2005-09-17 08:47:39 +0000
committerTomas Mraz <tm@t8m.info>2005-09-17 08:47:39 +0000
commit9801f8fdc051f8ea469d7ed8c06ccbf7a6a27cc9 (patch)
treea3e3e78caddfcafcdc5a0b6d78408cc704592c0a /libpam
parentc56638793ede5ac84067b9204d598bd6e0a7e34c (diff)
Relevant BUGIDs:
Purpose of commit: cleanup Commit summary: --------------- Better check the input parameters of pam_start (by ldv)
Diffstat (limited to 'libpam')
-rw-r--r--libpam/pam_start.c35
1 files 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);