* server_stubs.c (CHANGEPW_SERVICE): Modify to free allocated
authorEzra Peisach <epeisach@mit.edu>
Wed, 15 Oct 1997 01:19:09 +0000 (01:19 +0000)
committerEzra Peisach <epeisach@mit.edu>
Wed, 15 Oct 1997 01:19:09 +0000 (01:19 +0000)
          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
src/kadmin/server/ovsec_kadmd.c
src/kadmin/server/server_stubs.c

index 7d28b79baaeaf00d27dce33e708b43d194c78bfe..6f0b239c7a7bc0e21e910d875b8a7e7f14801bae 100644 (file)
@@ -1,3 +1,14 @@
+Tue Oct 14 21:06:16 1997  Ezra Peisach  <epeisach@mit.edu>
+
+       * 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  <tlyu@mit.edu>
 
        * kadm_rpc_svc.c, server_stubs.c: Add support for setv4key.
index bcacd72cecdc20f9b973b6892d5260b86ca7badf..16fb7d259e03a1843777e5cb17226c9872914c70 100644 (file)
@@ -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) {
index a4015b5c00df6a86f5da288318cdc628336d642c..7b8b573cb4a0cbc1956643e86a0c68b7116f7ab6 100644 (file)
@@ -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);