From ee735952aa05a83f92d09a67c15ca93cee1892d4 Mon Sep 17 00:00:00 2001 From: Ezra Peisach Date: Wed, 15 Oct 1997 01:19:09 +0000 Subject: [PATCH] * server_stubs.c (CHANGEPW_SERVICE): Modify to free allocated memory in request. (setup_gss_names): Free memory in case of failure. (chrand_principal_1): Call free_server_handle for failure cleanup. * ovsec_kadmd.c (main): Cleanup memory by calling acl_finish, gss_release_name, and krb5_free_context Some of these fixes are to make accounting easier with Purify upon shutdown while the server_stubs.c fixes take care of a per-request memory leak present for many requests. automatically CVS: CVS: Committing in . CVS: CVS: Modified Files: ---------------------------------------------------------------------- git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@10233 dc483132-0cff-0310-8789-dd5450dbe970 --- src/kadmin/server/ChangeLog | 11 +++++++++++ src/kadmin/server/ovsec_kadmd.c | 18 +++++++++++++++++- src/kadmin/server/server_stubs.c | 20 ++++++++++++++++++-- 3 files changed, 46 insertions(+), 3 deletions(-) diff --git a/src/kadmin/server/ChangeLog b/src/kadmin/server/ChangeLog index 7d28b79ba..6f0b239c7 100644 --- a/src/kadmin/server/ChangeLog +++ b/src/kadmin/server/ChangeLog @@ -1,3 +1,14 @@ +Tue Oct 14 21:06:16 1997 Ezra Peisach + + * server_stubs.c (CHANGEPW_SERVICE): Modify to free allocated + memory in request. + (setup_gss_names): Free memory in case of failure. + (chrand_principal_1): Call free_server_handle for failure + cleanup. + + * ovsec_kadmd.c (main): Cleanup memory by calling acl_finish, + gss_release_name, and krb5_free_context + Tue Jul 1 02:36:55 1997 Tom Yu * kadm_rpc_svc.c, server_stubs.c: Add support for setv4key. diff --git a/src/kadmin/server/ovsec_kadmd.c b/src/kadmin/server/ovsec_kadmd.c index bcacd72ce..16fb7d259 100644 --- a/src/kadmin/server/ovsec_kadmd.c +++ b/src/kadmin/server/ovsec_kadmd.c @@ -387,9 +387,25 @@ int main(int argc, char *argv[]) kadm_svc_run(); krb5_klog_syslog(LOG_INFO, "finished, exiting"); + + /* Clean up memory, etc */ kadm5_destroy(global_server_handle); close(s); + acl_finish(context, 0); + if(gss_changepw_name) { + (void) gss_release_name(&OMret, &gss_changepw_name); + } + if(gss_oldchangepw_name) { + (void) gss_release_name(&OMret, &gss_oldchangepw_name); + } + for(s = 0 ; s < 4; s++) { + if (names[s].name) { + free(names[s].name); + } + } + krb5_klog_close(); + krb5_free_context(context); exit(2); } @@ -740,7 +756,7 @@ void log_badauth_display_status_1(char *m, OM_uint32 code, int type, { OM_uint32 gssstat, minor_stat; gss_buffer_desc msg; - int msg_ctx; + OM_uint32 msg_ctx; msg_ctx = 0; while (1) { diff --git a/src/kadmin/server/server_stubs.c b/src/kadmin/server/server_stubs.c index a4015b5c0..7b8b573cb 100644 --- a/src/kadmin/server/server_stubs.c +++ b/src/kadmin/server/server_stubs.c @@ -26,9 +26,9 @@ extern gss_name_t gss_oldchangepw_name; extern void * global_server_handle; #define CHANGEPW_SERVICE(rqstp) \ - (cmp_gss_names(acceptor_name(rqstp->rq_svccred), gss_changepw_name) |\ + (cmp_gss_names_rel_1(acceptor_name(rqstp->rq_svccred), gss_changepw_name) |\ (gss_oldchangepw_name && \ - cmp_gss_names(acceptor_name(rqstp->rq_svccred), \ + cmp_gss_names_rel_1(acceptor_name(rqstp->rq_svccred), \ gss_oldchangepw_name))) int cmp_gss_names(gss_name_t n1, gss_name_t n2) @@ -42,6 +42,18 @@ int cmp_gss_names(gss_name_t n1, gss_name_t n2) return(equal); } +/* Does a comparison of the names and then releases the first entity */ +/* For use above in CHANGEPW_SERVICE */ +int cmp_gss_names_rel_1(gss_name_t n1, gss_name_t n2) +{ + OM_uint32 min_stat; + int ret; + + ret = cmp_gss_names(n1, n2); + if (n1) (void) gss_release_name(&min_stat, &n1); + return ret; +} + /* * Function check_handle * @@ -152,12 +164,15 @@ int setup_gss_names(struct svc_req *rqstp, NULL, NULL); if (maj_stat != GSS_S_COMPLETE) { gss_release_buffer(&min_stat, client_name); + gss_release_name(&min_stat, &server_gss_name); return -1; } if (gss_name_to_string(server_gss_name, server_name) != 0) { gss_release_buffer(&min_stat, client_name); + gss_release_name(&min_stat, &server_gss_name); return -1; } + gss_release_name(&min_stat, &server_gss_name); return 0; } @@ -750,6 +765,7 @@ chrand_principal_1(chrand_arg *arg, struct svc_req *rqstp) if (setup_gss_names(rqstp, &client_name, &service_name) < 0) { ret.code = KADM5_FAILURE; + free_server_handle(handle); return &ret; } krb5_unparse_name(handle->context, arg->princ, &prime_arg); -- 2.26.2