fix memory leaks in krb5_gss_import_name() and krb5_gss_inquire_cred()
authorTom Yu <tlyu@mit.edu>
Thu, 22 Sep 2005 02:48:09 +0000 (02:48 +0000)
committerTom Yu <tlyu@mit.edu>
Thu, 22 Sep 2005 02:48:09 +0000 (02:48 +0000)
* import_name.c (krb5_gss_import_name): Add missing free of tmp in
an error case to fix a memory leak.

* inq_cred.c (krb5_gss_inquire_cred): Memory leak fixes: call
krb5_gss_release_cred() with address of cred, not cred; add
missing call to krb5_gss_release_cred() in an error case.

ticket: new
target_version: 1.4.3
tags: pullup
component: krb5-libs

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@17386 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/gssapi/krb5/ChangeLog
src/lib/gssapi/krb5/import_name.c
src/lib/gssapi/krb5/inq_cred.c

index 17280db6a0bd68526fb4367fd4a1a488a0858f9d..98ed5fdeda85cfe144a9cd32529a9a3144b1c69c 100644 (file)
@@ -1,5 +1,12 @@
 2005-09-21  Tom Yu  <tlyu@mit.edu>
 
+       * import_name.c (krb5_gss_import_name): Add missing free of tmp in
+       an error case to fix a memory leak.
+
+       * inq_cred.c (krb5_gss_inquire_cred): Memory leak fixes: call
+       krb5_gss_release_cred() with address of cred, not cred; add
+       missing call to krb5_gss_release_cred() in an error case.
+
        * duplicate_name.c (krb5_gss_duplicate_name):
        * export_name.c (krb5_gss_export_name): Fix gsstest nit by
        clearing minor_status if no errors.
index 828ba67da958f240911e8843b98f8cad8a7009de..75cad9e2f92681e3ab53ed8fcb7c154e86cd2e8b 100644 (file)
@@ -187,6 +187,7 @@ krb5_gss_import_name(minor_status, input_name_buffer,
         
         stringrep = tmp2;
      } else {
+        xfree(tmp);
         krb5_free_context(context);
         return(GSS_S_BAD_NAMETYPE);
       }
index ec8578e4e836b40c10bec45c863fc3b00d239023..780e798707a23d7a10721b3248f765fd739666f6 100644 (file)
@@ -175,6 +175,9 @@ krb5_gss_inquire_cred(minor_status, cred_handle, name, lifetime_ret,
    if (name) {
       if (ret_name != NULL && ! kg_save_name((gss_name_t) ret_name)) {
         k5_mutex_unlock(&cred->lock);
+        if (cred_handle == GSS_C_NO_CREDENTIAL)
+            krb5_gss_release_cred(minor_status, (gss_cred_id_t)&cred);
+
         (void) gss_release_oid_set(minor_status, &mechs);
         krb5_free_principal(context, ret_name);
         *minor_status = (OM_uint32) G_VALIDATE_FAILED;
@@ -198,7 +201,7 @@ krb5_gss_inquire_cred(minor_status, cred_handle, name, lifetime_ret,
       *mechanisms = mechs;
 
    if (cred_handle == GSS_C_NO_CREDENTIAL)
-       krb5_gss_release_cred(minor_status, (gss_cred_id_t)cred);
+       krb5_gss_release_cred(minor_status, (gss_cred_id_t)&cred);
 
    krb5_free_context(context);
    *minor_status = 0;
@@ -207,7 +210,7 @@ fail:
    if (cred_handle == GSS_C_NO_CREDENTIAL) {
        OM_uint32 tmp_min_stat;
 
-       krb5_gss_release_cred(&tmp_min_stat, (gss_cred_id_t)cred);
+       krb5_gss_release_cred(&tmp_min_stat, (gss_cred_id_t)&cred);
    }
    krb5_free_context(context);
    return ret;