sdb: Fix NULL pointer deference if we return early
authorAndreas Schneider <asn@samba.org>
Mon, 15 Feb 2016 07:27:54 +0000 (08:27 +0100)
committerAlexander Bokovoy <ab@samba.org>
Thu, 2 Jun 2016 10:48:13 +0000 (12:48 +0200)
If we return because of a wrong realm in a cross forest trust case, we
do not have a skdc_entry allocated.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
source4/kdc/sdb_to_kdb.c

index ce05b6266332579885a7490cbcc144d1f0e4acf2..d842052117eaa2cdb44dc9964749801aa38b3014 100644 (file)
@@ -331,11 +331,14 @@ int sdb_entry_ex_to_kdb_entry_ex(krb5_context context,
 
        ZERO_STRUCTP(k);
 
-       skdc_entry = talloc_get_type(s->ctx, struct samba_kdc_entry);
+       if (s->ctx != NULL) {
+               skdc_entry = talloc_get_type(s->ctx, struct samba_kdc_entry);
 
-       k->e_data       = (void *)skdc_entry;
+               k->e_data       = (void *)skdc_entry;
 
-       talloc_set_destructor(skdc_entry, samba_kdc_kdb_entry_destructor);
+               talloc_set_destructor(skdc_entry,
+                                     samba_kdc_kdb_entry_destructor);
+       }
 
        return sdb_entry_ex_to_krb5_db_entry(context, &s->entry, k);
 }