]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3/lib/smbconf: add talloc_stackframe to smbconf_init_reg
authorJohn Mulligan <jmulligan@redhat.com>
Thu, 5 May 2022 14:05:49 +0000 (10:05 -0400)
committerJeremy Allison <jra@samba.org>
Fri, 6 May 2022 17:16:30 +0000 (17:16 +0000)
Previously, if this function was called without an existing stackframe
then uses of talloc_tos in source3/registry trigger a panic. Since we
intend to add patches that allow access to this call with Python
bindings, that will not typically have a talloc_stackframe already,  we
add a talloc_stackframe call around the call to
smbconf_init_reg_internal. This hides the use of talloc_tos in the
registry code from higher level code that needs to call smbconf.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
source3/lib/smbconf/smbconf_reg.c

index 52332ce6dd91a533cc11684817438e10a7dbd6f6..fc8aa62d0678079ff79a5acb8516d56b5e4831d5 100644 (file)
@@ -1234,5 +1234,13 @@ struct smbconf_ops smbconf_ops_reg = {
 sbcErr smbconf_init_reg(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx,
                        const char *path)
 {
-       return smbconf_init_internal(mem_ctx, conf_ctx, path, &smbconf_ops_reg);
+       /*
+        * this tmp_ctx stackframe is required to initialize the registry backend.
+        * Without it, the calls panics due to the use of talloc_tos in the
+        * source3/registry code.
+        */
+       TALLOC_CTX *tmp_ctx = talloc_stackframe();
+       sbcErr err = smbconf_init_internal(mem_ctx, conf_ctx, path, &smbconf_ops_reg);
+       talloc_free(tmp_ctx);
+       return err;
 }