[SCM] Samba Shared Repository - branch v4-0-test updated

Karolin Seeger kseeger at samba.org
Wed Aug 7 05:16:04 MDT 2013


The branch, v4-0-test has been updated
       via  9439729 Ensure gpfs kernel leases are wrapped in a become_root()/unbecome_root() pair.
       via  f17721e Wrap setting leases in become_root()/unbecome_root() to ensure correct delivery of signals.
       via  c3a6b78 Add torture tests to raw.eas to check sending Windows invalid names in the middle of an EA list.
       via  fee1915 Reply with correct trans2 message on a setpathinfo with a bad EA name.
       via  050c42d Ensure we do pathname processing before SD and EA processing in NTTRANS_CREATE.
       via  515f122 Ensure we can't create a file using NTTRANS with an invalid EA list.
       via  6a5fed3 Ensure we can't create a file using TRANS2_OPEN with an invalid EA list.
       via  64e27e2 Add error map of STATUS_INVALID_EA_NAME -> ERRDOS, ERRbadfile
       via  76996fe Add the ability to send an NTSTATUS result back with a trans2 reply so we can return a parameter block with an error code.
       via  2f76ebd Ensure we can't create a file using SMB2_CREATE with an invalid EA list.
       via  f89d994 Ensure we never return an EA name to a Windows client it can't handle.
       via  8f40e36 Ensure set_ea cannot set invalid Windows EA names.
       via  1f902e4 Add ea_list_has_invalid_name() function.
      from  c358417 Fix bug 9678 - Windows 8 Roaming profiles fail

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v4-0-test


- Log -----------------------------------------------------------------
commit 9439729feefdd0b962f1a4b9012e973b231cc569
Author: Ralph Wuerthner <ralphw at de.ibm.com>
Date:   Wed Jul 31 16:33:48 2013 -0700

    Ensure gpfs kernel leases are wrapped in a become_root()/unbecome_root() pair.
    
    Ensures correct lease owner for signal delivery.
    
    Signed-off-by: Ralph Wuerthner <ralphw at de.ibm.com>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Simo Sorce <idra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Thu Aug  1 03:57:11 CEST 2013 on sn-devel-104
    
    The last 2 patches address bug #10064 - Linux kernel oplock breaks can miss
    signals.
    
    Autobuild-User(v4-0-test): Karolin Seeger <kseeger at samba.org>
    Autobuild-Date(v4-0-test): Wed Aug  7 13:15:02 CEST 2013 on sn-devel-104

commit f17721ee7e3457d591497c2f62834a706d218794
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Jul 31 16:32:20 2013 -0700

    Wrap setting leases in become_root()/unbecome_root() to ensure correct delivery of signals.
    
    Remove workaround for Linux kernel bug https://bugzilla.kernel.org/show_bug.cgi?id=43336
    as we don't need to set capabilities when we're already root.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Simo Sorce <idra at samba.org>

commit c3a6b78ab1cec783d53d551fd9c063aad680f0fb
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Jul 9 16:37:48 2013 -0700

    Add torture tests to raw.eas to check sending Windows invalid names in the middle of an EA list.
    
    Add torture tests to probe the set of invalid
    Windows EA names.
    
    Bug 9992 - Windows error 0x800700FE when copying files with xattr names containing ":"
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    
    Autobuild-User(master): Andrew Bartlett <abartlet at samba.org>
    Autobuild-Date(master): Fri Jul 19 11:50:25 CEST 2013 on sn-devel-104

commit fee1915a2e24272506eef8272589a366c6b2711b
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Jul 16 09:14:12 2013 -0700

    Reply with correct trans2 message on a setpathinfo with a bad EA name.
    
    Bug 9992 - Windows error 0x800700FE when copying files with xattr names containing ":"
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 050c42d282ddcd311a3484a6cf041b7172eca62b
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Jul 16 11:05:10 2013 -0700

    Ensure we do pathname processing before SD and EA processing in NTTRANS_CREATE.
    
    Bug 9992 - Windows error 0x800700FE when copying files with xattr names containing ":"
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 515f1227d42a7aa8adee6a11539eb2720508509a
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Jul 9 15:54:39 2013 -0700

    Ensure we can't create a file using NTTRANS with an invalid EA list.
    
    Bug 9992 - Windows error 0x800700FE when copying files with xattr names containing ":"
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 6a5fed3e3492c5932f8c2e82a9288997a684b550
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Jul 9 15:59:53 2013 -0700

    Ensure we can't create a file using TRANS2_OPEN with an invalid EA list.
    
    Bug 9992 - Windows error 0x800700FE when copying files with xattr names containing ":"
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 64e27e2f4989368c11f6424824da8169e56811b1
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Jul 10 12:18:36 2013 -0700

    Add error map of STATUS_INVALID_EA_NAME -> ERRDOS, ERRbadfile
    
    (from Windows2012 tests).
    
    Bug 9992 - Windows error 0x800700FE when copying files with xattr names containing ":"
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 76996fe3a578d3689a7a06b0cd9c5128af556662
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Jul 10 12:38:41 2013 -0700

    Add the ability to send an NTSTATUS result back with a trans2 reply so we can return a parameter block with an error code.
    
    This is needed when returning a STATUS_INVALID_NAME result (tested
    from Windows 2012).
    
    Bug 9992 - Windows error 0x800700FE when copying files with xattr names containing ":"
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 2f76ebd5a7301d9b6205590e5df9590b6f5d4e8f
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Jul 9 16:02:50 2013 -0700

    Ensure we can't create a file using SMB2_CREATE with an invalid EA list.
    
    Bug 9992 - Windows error 0x800700FE when copying files with xattr names containing ":"
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit f89d99439c1b0f5ccd3835dba840d852c9b54b99
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Jul 9 16:21:18 2013 -0700

    Ensure we never return an EA name to a Windows client it can't handle.
    
    Bug 9992 - Windows error 0x800700FE when copying files with xattr names containing ":"
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 8f40e362acdbee77c610d0aa34538d86f0e3fb6d
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Jul 9 15:52:47 2013 -0700

    Ensure set_ea cannot set invalid Windows EA names.
    
    Bug 9992 - Windows error 0x800700FE when copying files with xattr names containing ":"
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 1f902e4e0ed6b75a5297557d1f896d17364f49d0
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Jul 9 15:50:47 2013 -0700

    Add ea_list_has_invalid_name() function.
    
    Invalid character list probed from Windows Server 2012.
    
    Bug 9992: Windows error 0x800700FE when copying files with xattr names containing ":"
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

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

Summary of changes:
 libcli/util/errormap.c      |    1 +
 selftest/knownfail          |    1 +
 source3/include/proto.h     |    2 +
 source3/lib/filename_util.c |   34 +++++++++++++
 source3/modules/vfs_gpfs.c  |    6 ++
 source3/smbd/blocking.c     |    2 +-
 source3/smbd/nttrans.c      |   86 ++++++++++++++++++++------------
 source3/smbd/oplock_linux.c |   33 ++++++++-----
 source3/smbd/proto.h        |    1 +
 source3/smbd/smb2_create.c  |    5 ++
 source3/smbd/trans2.c       |   86 +++++++++++++++++++++++++++-----
 source4/torture/raw/eas.c   |  114 +++++++++++++++++++++++++++++++++++++++++++
 12 files changed, 310 insertions(+), 61 deletions(-)


Changeset truncated at 500 lines:

diff --git a/libcli/util/errormap.c b/libcli/util/errormap.c
index 714e62c..3870619 100644
--- a/libcli/util/errormap.c
+++ b/libcli/util/errormap.c
@@ -54,6 +54,7 @@ static const struct {
  */
 	{ERRDOS,	ERRmoredata,	STATUS_BUFFER_OVERFLOW},
 	{ERRDOS,	ERRnofiles,	STATUS_NO_MORE_FILES},
+	{ERRDOS,	ERRbadfile,	STATUS_INVALID_EA_NAME},
 	{ERRDOS,	ERRnofiles,	NT_STATUS_NO_MORE_ENTRIES},
 	{ERRDOS,	ERRgeneral,	NT_STATUS_UNSUCCESSFUL},
 	{ERRDOS,	ERRbadfunc,	NT_STATUS_NOT_IMPLEMENTED},
diff --git a/selftest/knownfail b/selftest/knownfail
index 262b889..d249a25 100644
--- a/selftest/knownfail
+++ b/selftest/knownfail
@@ -65,6 +65,7 @@
 ^samba4.raw.session.expire1
 ^samba4.raw.rename.*.osxrename
 ^samba4.raw.rename.*.directory rename
+^samba4.raw.eas
 ^samba4.rpc.winreg.*security
 ^samba4.local.registry.(dir|ldb).check hive security
 ^samba4.local.registry.local.security
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 6856dd7..5f34193 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -1612,6 +1612,8 @@ NTSTATUS copy_smb_filename(TALLOC_CTX *ctx,
 			   struct smb_filename **smb_fname_out);
 bool is_ntfs_stream_smb_fname(const struct smb_filename *smb_fname);
 bool is_ntfs_default_stream_smb_fname(const struct smb_filename *smb_fname);
+bool is_invalid_windows_ea_name(const char *name);
+bool ea_list_has_invalid_name(struct ea_list *ea_list);
 
 /* The following definitions come from lib/dummyroot.c */
 
diff --git a/source3/lib/filename_util.c b/source3/lib/filename_util.c
index 9a6ab2b..89bd413 100644
--- a/source3/lib/filename_util.c
+++ b/source3/lib/filename_util.c
@@ -232,3 +232,37 @@ bool is_ntfs_default_stream_smb_fname(const struct smb_filename *smb_fname)
 
 	return strcasecmp_m(smb_fname->stream_name, "::$DATA") == 0;
 }
+
+/****************************************************************************
+ Filter out Windows invalid EA names (list probed from Windows 2012).
+****************************************************************************/
+
+static char bad_ea_name_chars[] = "\"*+,/:;<=>?[\\]|";
+
+bool is_invalid_windows_ea_name(const char *name)
+{
+	int i;
+	/* EA name is pulled as ascii so we can examine
+	   individual bytes here. */
+	for (i = 0; name[i] != 0; i++) {
+		int val = (name[i] & 0xff);
+		if (val < ' ' || strchr(bad_ea_name_chars, val)) {
+			return true;
+		}
+	}
+	return false;
+}
+
+bool ea_list_has_invalid_name(struct ea_list *ea_list)
+{
+	if (lp_posix_pathnames()) {
+		return false;
+	}
+
+	for (;ea_list; ea_list = ea_list->next) {
+		if (is_invalid_windows_ea_name(ea_list->ea.name)) {
+			return true;
+		}
+	}
+	return false;
+}
diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c
index a28d4a2..90c4375 100644
--- a/source3/modules/vfs_gpfs.c
+++ b/source3/modules/vfs_gpfs.c
@@ -107,7 +107,13 @@ static int vfs_gpfs_setlease(vfs_handle_struct *handle, files_struct *fsp,
 	START_PROFILE(syscall_linux_setlease);
 
 	if (config->leases) {
+		/*
+		 * Ensure the lease owner is root to allow
+		 * correct delivery of lease-break signals.
+		 */
+		become_root();
 		ret = set_gpfs_lease(fsp->fh->fd,leasetype);
+		unbecome_root();
 	}
 
 	END_PROFILE(syscall_linux_setlease);
diff --git a/source3/smbd/blocking.c b/source3/smbd/blocking.c
index 95d6c33..100944c 100644
--- a/source3/smbd/blocking.c
+++ b/source3/smbd/blocking.c
@@ -563,7 +563,7 @@ static bool process_trans2(struct blocking_lock_record *blr)
 
 	SSVAL(params,0,0);
 	/* Fake up max_data_bytes here - we know it fits. */
-	send_trans2_replies(blr->fsp->conn, blr->req, params, 2, NULL, 0, 0xffff);
+	send_trans2_replies(blr->fsp->conn, blr->req, NT_STATUS_OK, params, 2, NULL, 0, 0xffff);
 	return True;
 }
 
diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c
index 5595af2..ee0deb8 100644
--- a/source3/smbd/nttrans.c
+++ b/source3/smbd/nttrans.c
@@ -1097,6 +1097,43 @@ static void call_nt_transact_create(connection_struct *conn,
 	 */
 	create_options &= ~NTCREATEX_OPTIONS_MUST_IGNORE_MASK;
 
+	srvstr_get_path(ctx, params, req->flags2, &fname,
+			params+53, parameter_count-53,
+			STR_TERMINATE, &status);
+	if (!NT_STATUS_IS_OK(status)) {
+		reply_nterror(req, status);
+		goto out;
+	}
+
+	if (file_attributes & FILE_FLAG_POSIX_SEMANTICS) {
+		case_state = set_posix_case_semantics(ctx, conn);
+		if (!case_state) {
+			reply_nterror(req, NT_STATUS_NO_MEMORY);
+			goto out;
+		}
+	}
+
+	status = filename_convert(ctx,
+				conn,
+				req->flags2 & FLAGS2_DFS_PATHNAMES,
+				fname,
+				0,
+				NULL,
+				&smb_fname);
+
+	TALLOC_FREE(case_state);
+
+	if (!NT_STATUS_IS_OK(status)) {
+		if (NT_STATUS_EQUAL(status,NT_STATUS_PATH_NOT_COVERED)) {
+			reply_botherror(req,
+				NT_STATUS_PATH_NOT_COVERED,
+				ERRSRV, ERRbadpath);
+			goto out;
+		}
+		reply_nterror(req, status);
+		goto out;
+	}
+
 	/* Ensure the data_len is correct for the sd and ea values given. */
 	if ((ea_len + sd_len > data_count)
 	    || (ea_len > data_count) || (sd_len > data_count)
@@ -1147,43 +1184,26 @@ static void call_nt_transact_create(connection_struct *conn,
 			reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
 			goto out;
 		}
-	}
-
-	srvstr_get_path(ctx, params, req->flags2, &fname,
-			params+53, parameter_count-53,
-			STR_TERMINATE, &status);
-	if (!NT_STATUS_IS_OK(status)) {
-		reply_nterror(req, status);
-		goto out;
-	}
-
-	if (file_attributes & FILE_FLAG_POSIX_SEMANTICS) {
-		case_state = set_posix_case_semantics(ctx, conn);
-		if (!case_state) {
-			reply_nterror(req, NT_STATUS_NO_MEMORY);
-			goto out;
-		}
-	}
 
-	status = filename_convert(ctx,
-				conn,
-				req->flags2 & FLAGS2_DFS_PATHNAMES,
-				fname,
-				0,
-				NULL,
-				&smb_fname);
-
-	TALLOC_FREE(case_state);
+		if (ea_list_has_invalid_name(ea_list)) {
+			/* Realloc the size of parameters and data we will return */
+			if (flags & EXTENDED_RESPONSE_REQUIRED) {
+				/* Extended response is 32 more byyes. */
+				param_len = 101;
+			} else {
+				param_len = 69;
+			}
+			params = nttrans_realloc(ppparams, param_len);
+			if(params == NULL) {
+				reply_nterror(req, NT_STATUS_NO_MEMORY);
+				goto out;
+			}
 
-	if (!NT_STATUS_IS_OK(status)) {
-		if (NT_STATUS_EQUAL(status,NT_STATUS_PATH_NOT_COVERED)) {
-			reply_botherror(req,
-				NT_STATUS_PATH_NOT_COVERED,
-				ERRSRV, ERRbadpath);
+			memset(params, '\0', param_len);
+			send_nt_replies(conn, req, STATUS_INVALID_EA_NAME,
+				params, param_len, NULL, 0);
 			goto out;
 		}
-		reply_nterror(req, status);
-		goto out;
 	}
 
 	oplock_request = (flags & REQUEST_OPLOCK) ? EXCLUSIVE_OPLOCK : 0;
diff --git a/source3/smbd/oplock_linux.c b/source3/smbd/oplock_linux.c
index 7fa9b7c..dd772bf 100644
--- a/source3/smbd/oplock_linux.c
+++ b/source3/smbd/oplock_linux.c
@@ -75,26 +75,33 @@ int linux_set_lease_sighandler(int fd)
 int linux_setlease(int fd, int leasetype)
 {
 	int ret;
+	int saved_errno;
+
+	/*
+	 * Ensure the lease owner is root to allow
+	 * correct delivery of lease-break signals.
+	 */
+
+	become_root();
 
 	/* First set the signal handler. */
 	if (linux_set_lease_sighandler(fd) == -1) {
-		return -1;
+		saved_errno = errno;
+		ret = -1;
+		goto out;
 	}
 	ret = fcntl(fd, F_SETLEASE, leasetype);
-	if (ret == -1 && errno == EACCES) {
-		set_effective_capability(LEASE_CAPABILITY);
-		/*
-		 * Bug 8974 - work around Linux kernel bug
-		 * https://bugzilla.kernel.org/show_bug.cgi?id=43336.
-		 * "fcntl(F_SETLEASE) resets signal number when
-		 *  called multiple times"
-		 */
-		if (linux_set_lease_sighandler(fd) == -1) {
-			return -1;
-		}
-		ret = fcntl(fd, F_SETLEASE, leasetype);
+	if (ret == -1) {
+		saved_errno = errno;
 	}
 
+  out:
+
+	unbecome_root();
+
+	if (ret == -1) {
+		errno = saved_errno;
+	}
 	return ret;
 }
 
diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h
index 319e20e..b4f4501 100644
--- a/source3/smbd/proto.h
+++ b/source3/smbd/proto.h
@@ -1061,6 +1061,7 @@ NTSTATUS set_ea(connection_struct *conn, files_struct *fsp,
 struct ea_list *read_ea_list_entry(TALLOC_CTX *ctx, const char *pdata, size_t data_size, size_t *pbytes_used);
 void send_trans2_replies(connection_struct *conn,
 			struct smb_request *req,
+			NTSTATUS status,
 			 const char *params,
 			 int paramsize,
 			 const char *pdata,
diff --git a/source3/smbd/smb2_create.c b/source3/smbd/smb2_create.c
index c88224e..edbd50f 100644
--- a/source3/smbd/smb2_create.c
+++ b/source3/smbd/smb2_create.c
@@ -583,6 +583,11 @@ static struct tevent_req *smbd_smb2_create_send(TALLOC_CTX *mem_ctx,
 				tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
 				return tevent_req_post(req, ev);
 			}
+
+			if (ea_list_has_invalid_name(ea_list)) {
+				tevent_req_nterror(req, STATUS_INVALID_EA_NAME);
+				return tevent_req_post(req, ev);
+			}
 		}
 
 		if (mxac) {
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index c129946..6500040 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -344,6 +344,15 @@ static NTSTATUS get_ea_list_from_file_path(TALLOC_CTX *mem_ctx, connection_struc
 		    || samba_private_attr_name(names[i]))
 			continue;
 
+		/*
+		 * Filter out any underlying POSIX EA names
+		 * that a Windows client can't handle.
+		 */
+		if (!lp_posix_pathnames() &&
+				is_invalid_windows_ea_name(names[i])) {
+			continue;
+		}
+
 		listp = talloc(mem_ctx, struct ea_list);
 		if (listp == NULL) {
 			return NT_STATUS_NO_MEMORY;
@@ -622,6 +631,15 @@ NTSTATUS set_ea(connection_struct *conn, files_struct *fsp,
 		return NT_STATUS_INVALID_PARAMETER;
 	}
 
+	/*
+	 * Filter out invalid Windows EA names - before
+	 * we set *any* of them.
+	 */
+
+	if (ea_list_has_invalid_name(ea_list)) {
+		return STATUS_INVALID_EA_NAME;
+	}
+
 	fname = smb_fname->base_name;
 
 	for (;ea_list; ea_list = ea_list->next) {
@@ -877,6 +895,7 @@ static struct ea_list *ea_list_union(struct ea_list *name_list, struct ea_list *
 
 void send_trans2_replies(connection_struct *conn,
 			struct smb_request *req,
+			NTSTATUS status,
 			 const char *params,
 			 int paramsize,
 			 const char *pdata,
@@ -917,6 +936,14 @@ void send_trans2_replies(connection_struct *conn,
 
 	if(params_to_send == 0 && data_to_send == 0) {
 		reply_outbuf(req, 10, 0);
+		if (NT_STATUS_V(status)) {
+			uint8_t eclass;
+			uint32_t ecode;
+			ntstatus_to_dos(status, &eclass, &ecode);
+			error_packet_set((char *)req->outbuf,
+					eclass, ecode, status,
+					__LINE__,__FILE__);
+		}
 		show_msg((char *)req->outbuf);
 		if (!srv_send_smb(sconn,
 				(char *)req->outbuf,
@@ -1047,6 +1074,13 @@ void send_trans2_replies(connection_struct *conn,
 					 ERRDOS,ERRbufferoverflow,
 					 STATUS_BUFFER_OVERFLOW,
 					 __LINE__,__FILE__);
+		} else if (NT_STATUS_V(status)) {
+			uint8_t eclass;
+			uint32_t ecode;
+			ntstatus_to_dos(status, &eclass, &ecode);
+			error_packet_set((char *)req->outbuf,
+					eclass, ecode, status,
+					__LINE__,__FILE__);
 		}
 
 		/* Send the packet */
@@ -1218,6 +1252,20 @@ static void call_trans2open(connection_struct *conn,
 			reply_nterror(req, NT_STATUS_EAS_NOT_SUPPORTED);
 			goto out;
 		}
+
+		if (ea_list_has_invalid_name(ea_list)) {
+			int param_len = 30;
+			*pparams = (char *)SMB_REALLOC(*pparams, param_len);
+			if(*pparams == NULL ) {
+				reply_nterror(req, NT_STATUS_NO_MEMORY);
+				goto out;
+			}
+			params = *pparams;
+			memset(params, '\0', param_len);
+			send_trans2_replies(conn, req, STATUS_INVALID_EA_NAME,
+				params, param_len, NULL, 0, max_data_bytes);
+			goto out;
+		}
 	}
 
 	status = SMB_VFS_CREATE_FILE(
@@ -1293,7 +1341,7 @@ static void call_trans2open(connection_struct *conn,
 	}
 
 	/* Send the required number of replies */
-	send_trans2_replies(conn, req, params, 30, *ppdata, 0, max_data_bytes);
+	send_trans2_replies(conn, req, NT_STATUS_OK, params, 30, *ppdata, 0, max_data_bytes);
  out:
 	TALLOC_FREE(smb_fname);
 }
@@ -2657,7 +2705,7 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
 	SSVAL(params,6,0); /* Never an EA error */
 	SSVAL(params,8,last_entry_off);
 
-	send_trans2_replies(conn, req, params, 10, pdata, PTR_DIFF(p,pdata),
+	send_trans2_replies(conn, req, NT_STATUS_OK, params, 10, pdata, PTR_DIFF(p,pdata),
 			    max_data_bytes);
 
 	if ((! *directory) && dptr_path(sconn, dptr_num)) {
@@ -3008,7 +3056,7 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
 	SSVAL(params,4,0); /* Never an EA error */
 	SSVAL(params,6,last_entry_off);
 
-	send_trans2_replies(conn, req, params, 8, pdata, PTR_DIFF(p,pdata),
+	send_trans2_replies(conn, req, NT_STATUS_OK, params, 8, pdata, PTR_DIFF(p,pdata),
 			    max_data_bytes);
 
 	return;
@@ -3652,7 +3700,7 @@ static void call_trans2qfsinfo(connection_struct *conn,
 		return;
 	}
 
-	send_trans2_replies(conn, req, params, 0, *ppdata, data_len,
+	send_trans2_replies(conn, req, NT_STATUS_OK, params, 0, *ppdata, data_len,
 			    max_data_bytes);
 
 	DEBUG( 4, ( "%s info_level = %d\n",
@@ -3808,6 +3856,7 @@ static void call_trans2setfsinfo(connection_struct *conn,
 				}
 
 				send_trans2_replies(conn, req,
+						NT_STATUS_OK,
 						*pparams,
 						param_len,
 						*ppdata,
@@ -4340,7 +4389,7 @@ static void call_trans2qpipeinfo(connection_struct *conn,
 			return;
 	}
 
-	send_trans2_replies(conn, req, params, param_size, *ppdata, data_size,
+	send_trans2_replies(conn, req, NT_STATUS_OK, params, param_size, *ppdata, data_size,
 			    max_data_bytes);
 
 	return;
@@ -5545,7 +5594,7 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
 		return;
 	}
 
-	send_trans2_replies(conn, req, params, param_size, *ppdata, data_size,
+	send_trans2_replies(conn, req, NT_STATUS_OK, params, param_size, *ppdata, data_size,
 			    max_data_bytes);
 
 	return;
@@ -8110,7 +8159,7 @@ static void call_trans2setfilepathinfo(connection_struct *conn,
 					 fsp_str_dbg(fsp)));
 
 				SSVAL(params,0,0);
-				send_trans2_replies(conn, req, params, 2,
+				send_trans2_replies(conn, req, NT_STATUS_OK, params, 2,
 						    *ppdata, 0,
 						    max_data_bytes);
 				return;
@@ -8233,11 +8282,20 @@ static void call_trans2setfilepathinfo(connection_struct *conn,
 			return;
 		}
 
-		reply_nterror(req, status);
+		/*
+		 * Invalid EA name needs to return 2 param bytes,
+		 * not a zero-length error packet.
+		 */
+		if (NT_STATUS_EQUAL(status, STATUS_INVALID_EA_NAME)) {
+			send_trans2_replies(conn, req, status, params, 2, NULL, 0,
+					max_data_bytes);
+		} else {
+			reply_nterror(req, status);
+		}
 		return;
 	}
 
-	send_trans2_replies(conn, req, params, 2, *ppdata, data_return_size,
+	send_trans2_replies(conn, req, NT_STATUS_OK, params, 2, *ppdata, data_return_size,
 			    max_data_bytes);
 
 	return;
@@ -8362,7 +8420,7 @@ static void call_trans2mkdir(connection_struct *conn, struct smb_request *req,
 
 	SSVAL(params,0,0);
 
-	send_trans2_replies(conn, req, params, 2, *ppdata, 0, max_data_bytes);
+	send_trans2_replies(conn, req, NT_STATUS_OK, params, 2, *ppdata, 0, max_data_bytes);
 
  out:
 	TALLOC_FREE(smb_dname);
@@ -8417,7 +8475,7 @@ static void call_trans2findnotifyfirst(connection_struct *conn,
 	if(fnf_handle == 0)
 		fnf_handle = 257;
 
-	send_trans2_replies(conn, req, params, 6, *ppdata, 0, max_data_bytes);
+	send_trans2_replies(conn, req, NT_STATUS_OK, params, 6, *ppdata, 0, max_data_bytes);


-- 
Samba Shared Repository


More information about the samba-cvs mailing list