s3: Free principal if smb_krb5_principal_get_realm() fails
authorSwen Schillig <swen@linux.ibm.com>
Wed, 21 Nov 2018 11:05:24 +0000 (12:05 +0100)
committerRalph Boehme <slow@samba.org>
Thu, 22 Nov 2018 07:22:18 +0000 (08:22 +0100)
If smb_krb5_principal_get_realm() fails, procesing is aborted and
resources have to be free'd. In this context free'ing the principal
was missing.

Signed-off-by: Swen Schillig <swen@linux.ibm.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/libads/krb5_setpw.c

index 8f9098853b949fac5e63d61446e5badad91035f7..94dd8eefc9223e8977db72af0413b440dcb45df7 100644 (file)
@@ -221,6 +221,7 @@ static ADS_STATUS ads_krb5_chg_password(const char *kdc_host,
 
     /* We have to obtain an INITIAL changepw ticket for changing password */
     if (asprintf(&chpw_princ, "kadmin/changepw@%s", realm) == -1) {
+       krb5_free_principal(context, princ);
        krb5_get_init_creds_opt_free(context, opts);
        smb_krb5_free_addresses(context, addr);
        krb5_free_context(context);