Revert "s3-kerberos: use krb5 compat macros in fill_keytab_from_password()."
authorSimo Sorce <idra@samba.org>
Thu, 2 Sep 2010 20:07:00 +0000 (16:07 -0400)
committerGünther Deschner <gd@samba.org>
Thu, 2 Sep 2010 20:48:09 +0000 (22:48 +0200)
This reverts commit 9986d25ed195ee77bd73c96f057c527b4c3a8f03.

This patch was causing us to free unallocated memory.

Signed-off-by: Günther Deschner <gd@samba.org>
source3/librpc/rpc/dcerpc_krb5.c

index 2d39a45b6770c01461c17f2feea704a3b2219754..9e709d833486296a963f7b54b1d03221f7aae4d5 100644 (file)
@@ -128,7 +128,10 @@ static krb5_error_code fill_keytab_from_password(krb5_context krbctx,
        for (i = 0; enctypes[i]; i++) {
                krb5_keyblock *key = NULL;
 
-               key = KRB5_KT_KEY(&kt_entry);
+               if (!(key = SMB_MALLOC_P(krb5_keyblock))) {
+                       ret = ENOMEM;
+                       goto out;
+               }
 
                if (create_kerberos_key_from_string(krbctx, princ,
                                                    password, key,
@@ -136,11 +139,13 @@ static krb5_error_code fill_keytab_from_password(krb5_context krbctx,
                        DEBUG(10, ("Failed to create key for enctype %d "
                                   "(error: %s)\n",
                                   enctypes[i], error_message(ret)));
+                       SAFE_FREE(key);
                        continue;
                }
 
                kt_entry.principal = princ;
                kt_entry.vno = vno;
+               kt_entry.key = *key;
 
                ret = krb5_kt_add_entry(krbctx, keytab, &kt_entry);
                if (ret) {