kdc-db-glue: Fix memory cleanup to avoid crashes.
authorAndreas Schneider <asn@samba.org>
Wed, 25 Feb 2015 10:55:43 +0000 (11:55 +0100)
committerStefan Metzmacher <metze@samba.org>
Fri, 20 Mar 2015 22:25:54 +0000 (23:25 +0100)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
source4/kdc/db-glue.c

index 6bcfad5729c5316f1273fdb3941b962fe5052df9..7e955e746371f882d31752b44c4262acacdab5c0 100644 (file)
@@ -588,9 +588,9 @@ static krb5_error_code samba_kdc_message2entry(krb5_context context,
                is_computer = TRUE;
        }
 
-       memset(entry_ex, 0, sizeof(*entry_ex));
+       ZERO_STRUCTP(entry_ex);
 
-       p = talloc(mem_ctx, struct samba_kdc_entry);
+       p = talloc_zero(mem_ctx, struct samba_kdc_entry);
        if (!p) {
                ret = ENOMEM;
                goto out;
@@ -937,6 +937,7 @@ out:
        if (ret != 0) {
                /* This doesn't free ent itself, that is for the eventual caller to do */
                hdb_free_entry(context, entry_ex);
+               ZERO_STRUCTP(entry_ex);
        } else {
                talloc_steal(kdc_db_ctx, entry_ex->ctx);
        }