[SCM] Samba Shared Repository - branch master updated

Volker Lendecke vlendec at samba.org
Sat Mar 5 06:09:02 MST 2011


The branch, master has been updated
       via  dcbfb6f s3: Fix a memory leak in check_sam_security_info3
      from  f1a5109 s3:test: the registry roundtrip test passes now

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


- Log -----------------------------------------------------------------
commit dcbfb6fc0b9050168e2010673caccb7ec8807bd1
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Mar 5 12:57:59 2011 +0100

    s3: Fix a memory leak in check_sam_security_info3
    
    Abartlet, this commit makes check_sam_security_info3 use talloc_tos() and also
    cleans up the temporary talloc stackframe.
    
    The old code created a temporary talloc context off "mem_ctx" but failed to
    clean up the tmp_ctx in all but one return paths.
    
    talloc_stackframe()/talloc_tos() is designed as a defense against exactly this
    error: Even if we failed to free the frame when returning from the routine, it
    would be cleaned up very soon, in our main event loop.
    
    Please check this patch!
    
    Thanks,
    
    Volker
    
    Autobuild-User: Volker Lendecke <vlendec at samba.org>
    Autobuild-Date: Sat Mar  5 14:08:37 CET 2011 on sn-devel-104

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

Summary of changes:
 source3/auth/check_samsec.c |   22 ++++++++++++----------
 1 files changed, 12 insertions(+), 10 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/auth/check_samsec.c b/source3/auth/check_samsec.c
index 299f43a..db5f68f 100644
--- a/source3/auth/check_samsec.c
+++ b/source3/auth/check_samsec.c
@@ -519,29 +519,31 @@ NTSTATUS check_sam_security_info3(const DATA_BLOB *challenge,
 	struct auth_serversupplied_info *server_info = NULL;
 	struct netr_SamInfo3 *info3;
 	NTSTATUS status;
-	TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
-	if (!tmp_ctx) {
-		return NT_STATUS_NO_MEMORY;
-	}
-	status = check_sam_security(challenge, tmp_ctx, user_info, &server_info);
+	TALLOC_CTX *frame = talloc_stackframe();
+
+	status = check_sam_security(challenge, talloc_tos(), user_info,
+				    &server_info);
 	if (!NT_STATUS_IS_OK(status)) {
 		DEBUG(10, ("check_sam_security failed: %s\n",
 			   nt_errstr(status)));
-		return status;
+		goto done;
 	}
 
 	info3 = TALLOC_ZERO_P(mem_ctx, struct netr_SamInfo3);
 	if (info3 == NULL) {
-		talloc_free(tmp_ctx);
-		return NT_STATUS_NO_MEMORY;
+		status = NT_STATUS_NO_MEMORY;
+		goto done;
 	}
 
 	status = serverinfo_to_SamInfo3(server_info, NULL, 0, info3);
 	if (!NT_STATUS_IS_OK(status)) {
 		DEBUG(10, ("serverinfo_to_SamInfo3 failed: %s\n",
 			   nt_errstr(status)));
-		return status;
+		goto done;
 	}
 	*pinfo3 = info3;
-	return NT_STATUS_OK;
+	status =  NT_STATUS_OK;
+done:
+	TALLOC_FREE(frame);
+	return status;
 }


-- 
Samba Shared Repository


More information about the samba-cvs mailing list