svn commit: samba r20336 - in branches/SAMBA_3_0/source/smbd: .

vlendec at samba.org vlendec at samba.org
Sat Dec 23 19:35:37 GMT 2006


Author: vlendec
Date: 2006-12-23 19:35:36 +0000 (Sat, 23 Dec 2006)
New Revision: 20336

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=20336

Log:
Fix some memleaks in trans2open and simplify trans2mkdir a bit: We now have
tmp_talloc_ctx().

Volker

Modified:
   branches/SAMBA_3_0/source/smbd/trans2.c


Changeset:
Modified: branches/SAMBA_3_0/source/smbd/trans2.c
===================================================================
--- branches/SAMBA_3_0/source/smbd/trans2.c	2006-12-23 18:55:08 UTC (rev 20335)
+++ branches/SAMBA_3_0/source/smbd/trans2.c	2006-12-23 19:35:36 UTC (rev 20336)
@@ -753,7 +753,6 @@
 	int smb_action = 0;
 	BOOL bad_path = False;
 	files_struct *fsp;
-	TALLOC_CTX *ctx = NULL;
 	struct ea_list *ea_list = NULL;
 	uint16 flags = 0;
 	NTSTATUS status;
@@ -835,13 +834,9 @@
 			return ERROR_NT(NT_STATUS_INVALID_PARAMETER);
 		}
 
-		ctx = talloc_init("TRANS2_OPEN_SET_EA");
-		if (!ctx) {
-			return ERROR_NT(NT_STATUS_NO_MEMORY);
-		}
-		ea_list = read_ea_list(ctx, pdata + 4, total_data - 4);
+		ea_list = read_ea_list(tmp_talloc_ctx(), pdata + 4,
+				       total_data - 4);
 		if (!ea_list) {
-			talloc_destroy(ctx);
 			return ERROR_NT(NT_STATUS_INVALID_PARAMETER);
 		}
 	} else if (IVAL(pdata,0) != 4) {
@@ -858,7 +853,6 @@
 		&smb_action, &fsp);
       
 	if (!NT_STATUS_IS_OK(status)) {
-		talloc_destroy(ctx);
 		if (open_was_deferred(SVAL(inbuf,smb_mid))) {
 			/* We have re-scheduled this call. */
 			return -1;
@@ -871,7 +865,6 @@
 	mtime = sbuf.st_mtime;
 	inode = sbuf.st_ino;
 	if (fattr & aDIR) {
-		talloc_destroy(ctx);
 		close_file(fsp,ERROR_CLOSE);
 		return(ERROR_DOS(ERRDOS,ERRnoaccess));
 	}
@@ -900,9 +893,8 @@
                 }
 	}
 
-	if (total_data && smb_action == FILE_WAS_CREATED) {
+	if (ea_list && smb_action == FILE_WAS_CREATED) {
 		status = set_ea(conn, fsp, fname, ea_list);
-		talloc_destroy(ctx);
 		if (!NT_STATUS_IS_OK(status)) {
 			close_file(fsp,ERROR_CLOSE);
 			return ERROR_NT(status);
@@ -4776,7 +4768,6 @@
 	SMB_STRUCT_STAT sbuf;
 	BOOL bad_path = False;
 	NTSTATUS status = NT_STATUS_OK;
-	TALLOC_CTX *ctx = NULL;
 	struct ea_list *ea_list = NULL;
 	files_struct *fsp;
 
@@ -4821,13 +4812,9 @@
 			return ERROR_NT(NT_STATUS_INVALID_PARAMETER);
 		}
 
-		ctx = talloc_init("TRANS2_MKDIR_SET_EA");
-		if (!ctx) {
-			return ERROR_NT(NT_STATUS_NO_MEMORY);
-		}
-		ea_list = read_ea_list(ctx, pdata + 4, total_data - 4);
+		ea_list = read_ea_list(tmp_talloc_ctx(), pdata + 4,
+				       total_data - 4);
 		if (!ea_list) {
-			TALLOC_FREE(ctx);
 			return ERROR_NT(NT_STATUS_INVALID_PARAMETER);
 		}
 	} else if (IVAL(pdata,0) != 4) {
@@ -4835,7 +4822,6 @@
 	}
 
 	if (!check_name(directory,conn)) {
-		TALLOC_FREE(ctx);
 		DEBUG(5,("call_trans2mkdir error (%s)\n", strerror(errno)));
 		return set_bad_path_error(errno, bad_path, outbuf, ERRDOS,
 					  ERRnoaccess);
@@ -4847,7 +4833,6 @@
 				FILE_CREATE, 0, NULL, &fsp);
 
 	if (!NT_STATUS_IS_OK(status)) {
-		TALLOC_FREE(ctx);
 		return ERROR_NT(status);
 	}
 	close_file(fsp, NORMAL_CLOSE);
@@ -4855,7 +4840,6 @@
 	/* Try and set any given EA. */
 	if (ea_list) {
 		status = set_ea(conn, NULL, directory, ea_list);
-		TALLOC_FREE(ctx);
 		if (!NT_STATUS_IS_OK(status)) {
 			return ERROR_NT(status);
 		}



More information about the samba-cvs mailing list