Small leak in kadm5_get_init_creds

Jerry James Jerry.James at usu.edu
Fri Mar 9 11:44:26 EST 2007


I found this on Fedora Core 6, which is using 1.5, but I downloaded the
sources and found the same leak is present in 1.6.  The function
kadm5_get_init_creds fails to clean up a principal before exiting.  This
patch plugs the leak.

--- src/lib/kadm5/clnt/client_init.c.ORIG	2006-05-15 19:45:00.000000000 -0600
+++ src/lib/kadm5/clnt/client_init.c	2007-03-03 19:57:26.000000000 -0700
@@ -410,7 +410,7 @@
 		      strlen(krb5_cc_get_name(handle->context, ccache)) + 2);
 	  if (handle->cache_name == NULL) {
 	       code = ENOMEM;
-	       goto error;
+	       goto error2;
 	  }
 	  sprintf(handle->cache_name, "%s:%s",
 		  krb5_cc_get_type(handle->context, ccache),
@@ -425,11 +425,11 @@
 	  code = krb5_cc_resolve(handle->context, handle->cache_name,
 				 &ccache);
 	  if (code) 
-	       goto error;
+	       goto error2;
 
 	  code = krb5_cc_initialize (handle->context, ccache, client);
 	  if (code) 
-	       goto error;
+	       goto error2;
 
 	  handle->destroy_cache = 1;
      }
@@ -451,6 +451,8 @@
      if (code == KRB5KDC_ERR_S_PRINCIPAL_UNKNOWN)
 	  code = KADM5_SECURE_PRINC_MISSING;
 
+error2:
+     krb5_free_principal(handle->context, client);
 error:
      if (ccache != NULL && init_type != INIT_CREDS)
 	  krb5_cc_close(handle->context, ccache);

I first sent this to kerberos at mit.edu, but the list management software
classified the patch (which was attached) as a binary and quarantined
it, and also threw away the text part of my message.  Is it configured
that way on purpose?

Regards,
-- 
Jerry James, Assistant Professor        Jerry.James at usu.edu
Computer Science Department             http://www.cs.usu.edu/~jerry/
Utah State University



More information about the krbdev mailing list