]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
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)
committerKarolin Seeger <kseeger@samba.org>
Tue, 5 Dec 2017 09:32:10 +0000 (10:32 +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>
(cherry picked from commit 1fc103547023aa1c880713e5b65ec164acb58b54)

source3/param/loadparm.c

index d8da749ccba122e6b310a8fdfd2b9a09a23e733f..bc82d54fc484ef4703cf56df9e9c21fbaade9ec8 100644 (file)
@@ -949,7 +949,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;