[SCM] Samba Shared Repository - branch master updated

Günther Deschner gd at samba.org
Wed Nov 11 15:03:02 UTC 2020


The branch, master has been updated
       via  457b49c6780 s3: modules: gluster. Fix the error I made in preventing talloc leaks from a function.
      from  31c703766fd lookup_name: allow lookup names prefixed with DNS forest root for FreeIPA DC

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 457b49c67803dd95abc8502c2a410fac273f6fba
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Nov 10 10:18:18 2020 -0800

    s3: modules: gluster. Fix the error I made in preventing talloc leaks from a function.
    
    file_lines_parse() plays horrible tricks with
    the passed-in talloc pointers and the hierarcy
    which makes freeing hard to get right.
    
    As we know mem_ctx is freed by the caller, after
    calling file_lines_parse don't free on exit and let the caller
    handle it. This violates good Samba coding practice
    but we know we're not leaking here.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14486
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Guenther Deschner <gd at samba.org>
    
    Autobuild-User(master): Günther Deschner <gd at samba.org>
    Autobuild-Date(master): Wed Nov 11 15:02:27 UTC 2020 on sn-devel-184

-----------------------------------------------------------------------

Summary of changes:
 source3/modules/vfs_glusterfs.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/modules/vfs_glusterfs.c b/source3/modules/vfs_glusterfs.c
index 1ed6235e37f..c438a64d9be 100644
--- a/source3/modules/vfs_glusterfs.c
+++ b/source3/modules/vfs_glusterfs.c
@@ -315,15 +315,25 @@ static int check_for_write_behind_translator(TALLOC_CTX *mem_ctx,
 		return -1;
 	}
 
+	/*
+	 * file_lines_parse() plays horrible tricks with
+	 * the passed-in talloc pointers and the hierarcy
+	 * which makes freeing hard to get right.
+	 *
+	 * As we know mem_ctx is freed by the caller, after
+	 * this point don't free on exit and let the caller
+	 * handle it. This violates good Samba coding practice
+	 * but we know we're not leaking here.
+	 */
+
 	lines = file_lines_parse(buf,
 				newlen,
 				&numlines,
 				mem_ctx);
 	if (lines == NULL || numlines <= 0) {
-		TALLOC_FREE(option);
-		TALLOC_FREE(buf);
 		return -1;
 	}
+	/* On success, buf is now a talloc child of lines !! */
 
 	for (i=0; i < numlines; i++) {
 		if (strequal(lines[i], option)) {
@@ -338,15 +348,9 @@ static int check_for_write_behind_translator(TALLOC_CTX *mem_ctx,
 			"Please check the vfs_glusterfs(8) manpage for "
 			"further details.\n",
 			volume);
-		TALLOC_FREE(lines);
-		TALLOC_FREE(option);
-		TALLOC_FREE(buf);
 		return -1;
 	}
 
-	TALLOC_FREE(lines);
-	TALLOC_FREE(option);
-	TALLOC_FREE(buf);
 	return 0;
 }
 


-- 
Samba Shared Repository



More information about the samba-cvs mailing list