]> 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)
committerGreg Hudson <ghudson@mit.edu>
Wed, 10 Aug 2016 17:36:50 +0000 (13:36 -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.

ticket: 8437 (new)
target_version: 1.14-next
target_version: 1.13-next
tags: pullup

src/lib/gssapi/krb5/acquire_cred.c

index 2247c497f3065df6d43f9cbe0c4e9c314e6b235b..03ee25ec186121fa555f50d95cbb021064c871dc 100644 (file)
@@ -864,8 +864,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
@@ -876,6 +880,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);
     }