s3/loadparm: allocate a fresh sDefault object per lp_ctx
authorRalph Boehme <slow@samba.org>
Wed, 22 Nov 2017 10:49:57 +0000 (11:49 +0100)
committerJeremy Allison <jra@samba.org>
Mon, 27 Nov 2017 21:08:17 +0000 (22:08 +0100)
This is in preperation of preventing direct access to sDefault in all
places that currently modify it.

As currently s3/loadparm is afaict not accessing lp_ctx->sDefault, but
changes sDefault indirectly through lp_parm_ptr() this change is just a
safety measure to prevent future breakage.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=13051

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/param/loadparm.c

index d34632467049ea6b09bd4e8f02e06563fed1440b..433727b3f7982ff9f6b51d7144938990a539ce4d 100644 (file)
@@ -968,7 +968,14 @@ static struct loadparm_context *setup_lp_context(TALLOC_CTX *mem_ctx)
                return NULL;
        }
 
-       lp_ctx->sDefault = &sDefault;
+       lp_ctx->sDefault = talloc_zero(lp_ctx, struct loadparm_service);
+       if (lp_ctx->sDefault == NULL) {
+               DBG_ERR("talloc_zero failed\n");
+               TALLOC_FREE(lp_ctx);
+               return NULL;
+       }
+
+       *lp_ctx->sDefault = sDefault;
        lp_ctx->services = NULL; /* We do not want to access this directly */
        lp_ctx->bInGlobalSection = bInGlobalSection;
        lp_ctx->flags = flags_list;