gss: free user keytab before resolving system keytab
authorLuke Howard <lukeh@padl.com>
Thu, 16 Apr 2020 07:19:35 +0000 (07:19 +0000)
committerLuke Howard <lukeh@padl.com>
Thu, 16 Apr 2020 07:22:31 +0000 (17:22 +1000)
get_client_keytab() leaked the user keytab if it resolved but we could not find
the client principal. Free it before trying the system keytab.

lib/gssapi/krb5/acquire_cred.c

index 4ccad45dd202c201c70ffaa6c145474757ec1976..ba5d48fadab6b97e7803cc64014bef1117819616 100644 (file)
@@ -157,8 +157,14 @@ get_client_keytab(krb5_context context,
            krb5_kt_free_entry(context, &entry);
     }
 
-    if (ret)
+    if (ret) {
+       if (*keytab) {
+           krb5_kt_close(context, *keytab);
+           *keytab = NULL;
+       }
+
        ret = get_system_keytab(context, GSS_C_NO_CRED_STORE, keytab);
+    }
 
     return ret;
 }