]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Fix leaks on error in krb5 gss_acquire_cred()
authorGreg Hudson <ghudson@mit.edu>
Mon, 27 Jun 2016 21:49:57 +0000 (17:49 -0400)
committerTom Yu <tlyu@mit.edu>
Fri, 2 Sep 2016 22:27:05 +0000 (18:27 -0400)
In acquire_cred_context(), when releasing the partially constructed
cred on error, make sure to free the password and impersonator fields,
and to destroy the ccache if we created it.

(cherry picked from commit ee7315964e52fe351ddb6884e0e8baf1ecce2144)

ticket: 8437
version_fixed: 1.13.7

src/lib/gssapi/krb5/acquire_cred.c

index 8bdf7c417785b37fad4e6aaf86687560ae2ea9e7..a8199c57e4e9199953698ce198071f75196c751f 100644 (file)
@@ -836,8 +836,12 @@ krb_error_out:
 
 error_out:
     if (cred != NULL) {
-        if (cred->ccache)
-            krb5_cc_close(context, cred->ccache);
+        if (cred->ccache) {
+            if (cred->destroy_ccache)
+                krb5_cc_destroy(context, cred->ccache);
+            else
+                krb5_cc_close(context, cred->ccache);
+        }
         if (cred->client_keytab)
             krb5_kt_close(context, cred->client_keytab);
 #ifndef LEAN_CLIENT
@@ -848,6 +852,8 @@ error_out:
             krb5_rc_close(context, cred->rcache);
         if (cred->name)
             kg_release_name(context, &cred->name);
+        krb5_free_principal(context, cred->impersonator);
+        zapfreestr(cred->password);
         k5_mutex_destroy(&cred->lock);
         xfree(cred);
     }