aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Horowitz <marc@mit.edu>1998-10-06 06:37:59 +0000
committerMarc Horowitz <marc@mit.edu>1998-10-06 06:37:59 +0000
commit3694def2248bf8a3f565c318d3dc121163ab5020 (patch)
tree40add9fe6e2fb4b2e6e1e4ecde226538b86ed44c
parent398c6a3260489bfa25a06358bba419eaed031b1c (diff)
downloadkrb5-3694def2248bf8a3f565c318d3dc121163ab5020.zip
krb5-3694def2248bf8a3f565c318d3dc121163ab5020.tar.gz
krb5-3694def2248bf8a3f565c318d3dc121163ab5020.tar.bz2
plug the leak in set_names, and add an unset_names function so we can
plug other leaks git-svn-id: svn://anonsvn.mit.edu/krb5/branches/marc-3des@10963 dc483132-0cff-0310-8789-dd5450dbe970
-rw-r--r--src/lib/rpc/svc_auth_gssapi.c43
1 files changed, 36 insertions, 7 deletions
diff --git a/src/lib/rpc/svc_auth_gssapi.c b/src/lib/rpc/svc_auth_gssapi.c
index 2a3233e..df59859 100644
--- a/src/lib/rpc/svc_auth_gssapi.c
+++ b/src/lib/rpc/svc_auth_gssapi.c
@@ -887,7 +887,7 @@ done:
}
/*
- * Function: _svcauth_gssapi_set_name
+ * Function: _svcauth_gssapi_set_names
*
* Purpose: Sets the list of service names for which incoming
* authentication requests should be honored.
@@ -917,6 +917,13 @@ bool_t _svcauth_gssapi_set_names(names, num)
goto fail;
for (i = 0; i < num; i++) {
+ server_name_list[i] = 0;
+ server_creds_list[i] = 0;
+ }
+
+ server_creds_count = num;
+
+ for (i = 0; i < num; i++) {
in_buf.value = names[i].name;
in_buf.length = strlen(in_buf.value) + 1;
@@ -939,19 +946,41 @@ bool_t _svcauth_gssapi_set_names(names, num)
}
}
- server_creds_count = num;
-
return TRUE;
fail:
- /* memory leak: not releasing names/creds already acquired */
- if (server_creds_list)
+ _svcauth_gssapi_unset_names();
+
+ return FALSE;
+}
+
+/* Function: _svcauth_gssapi_unset_names
+ *
+ * Purpose: releases the names and credentials allocated by
+ * _svcauth_gssapi_set_names
+ */
+
+void _svcauth_gssapi_unset_names()
+{
+ int i;
+ OM_uint32 minor_stat;
+
+ if (server_creds_list) {
+ for (i = 0; i < server_creds_count; i++)
+ if (server_creds_list[i])
+ gss_release_cred(&minor_stat, &server_creds_list[i]);
free(server_creds_list);
- if (server_name_list)
+ }
+
+ if (server_name_list) {
+ for (i = 0; i < server_creds_count; i++)
+ if (server_name_list[i])
+ gss_release_name(&minor_stat, &server_name_list[i]);
free(server_name_list);
- return FALSE;
+ }
}
+
/*
* Function: _svcauth_gssapi_set_log_badauth_func
*