Fix segfualt caused by incorrect configuration. If lp_realm() was not set,
authorAndrew Bartlett <abartlet@samba.org>
Tue, 6 Jan 2004 23:57:12 +0000 (23:57 +0000)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 6 Jan 2004 23:57:12 +0000 (23:57 +0000)
but security=ADS, we would attempt to free the principal name that krb5
never allocated.

Also fix the dump_data() of the session key, now that we use a data_blob to
store that.

Andrew Bartlett
(This used to be commit 4ad67f13404ef0118265ad66d8bdfa256c914ad0)

source3/libads/kerberos_verify.c

index b0efb8f598f15dc6cb55bb473adb1ea8bef8f07c..50e69718154d3458f620d3879bd774cccee68ca6 100644 (file)
@@ -173,8 +173,11 @@ NTSTATUS ads_verify_ticket(const char *realm, const DATA_BLOB *ticket,
        krb5_rcache rcache = NULL;
        int ret, i;
        krb5_keyblock *key = NULL;
+
        krb5_principal host_princ;
        char *host_princ_s = NULL;
+       BOOL free_host_princ = False;
+
        fstring myname;
        char *password_s = NULL;
        krb5_data password;
@@ -239,6 +242,8 @@ NTSTATUS ads_verify_ticket(const char *realm, const DATA_BLOB *ticket,
                goto out;
        }
 
+       free_host_princ = True;
+
        /*
         * JRA. We must set the rcache here. This will prevent replay attacks.
         */
@@ -339,10 +344,7 @@ NTSTATUS ads_verify_ticket(const char *realm, const DATA_BLOB *ticket,
        free(packet.data);
 
        get_krb5_smb_session_key(context, auth_context, session_key, True);
-#ifdef DEBUG_PASSWORD
-       DEBUG(10,("SMB session key (from ticket) follows:\n"));
-       dump_data(10, session_key, 16);
-#endif
+       dump_data_pw("SMB session key (from ticket)\n", session_key->data, session_key->length);
 
 #if 0
        file_save("/tmp/ticket.dat", ticket->data, ticket->length);
@@ -386,7 +388,9 @@ NTSTATUS ads_verify_ticket(const char *realm, const DATA_BLOB *ticket,
        if (!NT_STATUS_IS_OK(sret))
                data_blob_free(ap_rep);
 
-       krb5_free_principal(context, host_princ);
+       if (free_host_princ)
+               krb5_free_principal(context, host_princ);
+
        if (tkt != NULL)
                krb5_free_ticket(context, tkt);
        free_kerberos_etypes(context, enctypes);