krb5 commit: Fix localauth memory leak

Greg Hudson ghudson at MIT.EDU
Mon Aug 12 15:26:59 EDT 2013


https://github.com/krb5/krb5/commit/37eb601a1294244b179cb0e6e6cfb4a16709ccfa
commit 37eb601a1294244b179cb0e6e6cfb4a16709ccfa
Author: Greg Hudson <ghudson at mit.edu>
Date:   Mon Aug 12 15:17:20 2013 -0400

    Fix localauth memory leak
    
    localauth modules were not freed by krb5_free_context(), causing a
    memory leak.

 src/lib/krb5/krb/init_ctx.c  |    1 +
 src/lib/krb5/libkrb5.exports |    1 +
 src/lib/krb5/os/localauth.c  |    7 +++++++
 src/lib/krb5/os/os-proto.h   |    1 +
 4 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/src/lib/krb5/krb/init_ctx.c b/src/lib/krb5/krb/init_ctx.c
index 58eb01a..39b6853 100644
--- a/src/lib/krb5/krb/init_ctx.c
+++ b/src/lib/krb5/krb/init_ctx.c
@@ -310,6 +310,7 @@ krb5_free_context(krb5_context ctx)
 #endif
 
     k5_ccselect_free_context(ctx);
+    k5_localauth_free_context(ctx);
     k5_plugin_free_context(ctx);
     free(ctx->plugin_base_dir);
 
diff --git a/src/lib/krb5/libkrb5.exports b/src/lib/krb5/libkrb5.exports
index 3ade55f..665db7f 100644
--- a/src/lib/krb5/libkrb5.exports
+++ b/src/lib/krb5/libkrb5.exports
@@ -117,6 +117,7 @@ k5_free_pa_otp_req
 k5_free_serverlist
 k5_init_trace
 k5_kt_get_principal
+k5_localauth_free_context
 k5_locate_kdc
 k5_os_free_context
 k5_os_init_context
diff --git a/src/lib/krb5/os/localauth.c b/src/lib/krb5/os/localauth.c
index 81ab5d8..8e1a3a3 100644
--- a/src/lib/krb5/os/localauth.c
+++ b/src/lib/krb5/os/localauth.c
@@ -434,3 +434,10 @@ krb5_aname_to_localname(krb5_context context, krb5_const_principal aname,
     }
     return KRB5_LNAME_NOTRANS;
 }
+
+void
+k5_localauth_free_context(krb5_context context)
+{
+    free_handles(context, context->localauth_handles);
+    context->localauth_handles = NULL;
+}
diff --git a/src/lib/krb5/os/os-proto.h b/src/lib/krb5/os/os-proto.h
index 18c4dc4..e2891a1 100644
--- a/src/lib/krb5/os/os-proto.h
+++ b/src/lib/krb5/os/os-proto.h
@@ -146,6 +146,7 @@ extern unsigned int krb5_max_skdc_timeout;
 extern unsigned int krb5_skdc_timeout_shift;
 extern unsigned int krb5_skdc_timeout_1;
 
+void k5_localauth_free_context(krb5_context);
 krb5_error_code localauth_names_initvt(krb5_context context, int maj_ver,
                                        int min_ver, krb5_plugin_vtable vtable);
 krb5_error_code localauth_rule_initvt(krb5_context context, int maj_ver,


More information about the cvs-krb5 mailing list