[SCM] Samba Shared Repository - branch master updated - ae1d6020f0a6565959287c229fb7ecd7f5f40231

Volker Lendecke vlendec at samba.org
Fri Dec 19 21:39:54 GMT 2008


The branch, master has been updated
       via  ae1d6020f0a6565959287c229fb7ecd7f5f40231 (commit)
       via  fa5f11279bda32dcb9a85c74b2b4a967a8e52104 (commit)
       via  ae0c6cff25c2be64fb5d19e738e449f845551d8c (commit)
      from  13eefa7c435cb5ac656f662c78260a82caf43180 (commit)

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


- Log -----------------------------------------------------------------
commit ae1d6020f0a6565959287c229fb7ecd7f5f40231
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Dec 19 18:15:30 2008 +0100

    Fix setting smb_len for huge write&x calls

commit fa5f11279bda32dcb9a85c74b2b4a967a8e52104
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Dec 19 18:12:44 2008 +0100

    Add the cli_wct_ofs routine to calculate the offset for write&x

commit ae0c6cff25c2be64fb5d19e738e449f845551d8c
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Dec 19 18:07:44 2008 +0100

    Remove the direct inbuf reference from construct_reply_common()

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

Summary of changes:
 source3/include/async_smb.h |    2 +
 source3/include/proto.h     |    2 -
 source3/libsmb/async_smb.c  |   46 ++++++++++++++++++++++++++++++++++++++++++-
 source3/smbd/process.c      |   19 ++++++++++-------
 4 files changed, 58 insertions(+), 11 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/include/async_smb.h b/source3/include/async_smb.h
index ef53ee2..7fc4ff7 100644
--- a/source3/include/async_smb.h
+++ b/source3/include/async_smb.h
@@ -122,6 +122,8 @@ struct async_req *cli_request_send(TALLOC_CTX *mem_ctx,
 				   size_t bytes_alignment,
 				   uint32_t num_bytes, const uint8_t *bytes);
 
+uint16_t cli_wct_ofs(const struct cli_state *cli);
+
 bool cli_chain_cork(struct cli_state *cli, struct event_context *ev,
 		    size_t size_hint);
 void cli_chain_uncork(struct cli_state *cli);
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 212bbf0..25161fe 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -7489,8 +7489,6 @@ struct idle_event *event_add_idle(struct event_context *event_ctx,
 				  void *private_data);
 NTSTATUS allow_new_trans(struct trans_state *list, int mid);
 void respond_to_all_remaining_local_messages(void);
-bool create_outbuf(TALLOC_CTX *mem_ctx, const char *inbuf, char **outbuf,
-		   uint8_t num_words, uint32_t num_bytes);
 void reply_outbuf(struct smb_request *req, uint8 num_words, uint32 num_bytes);
 const char *smb_fn_name(int type);
 void add_to_common_flags2(uint32 v);
diff --git a/source3/libsmb/async_smb.c b/source3/libsmb/async_smb.c
index fdcbb00..82a9194 100644
--- a/source3/libsmb/async_smb.c
+++ b/source3/libsmb/async_smb.c
@@ -552,6 +552,7 @@ bool cli_chain_cork(struct cli_state *cli, struct event_context *ev,
 void cli_chain_uncork(struct cli_state *cli)
 {
 	struct cli_request *req = cli->chain_accumulator;
+	size_t smblen;
 
 	SMB_ASSERT(req != NULL);
 
@@ -561,7 +562,19 @@ void cli_chain_uncork(struct cli_state *cli)
 	cli->chain_accumulator = NULL;
 
 	SSVAL(req->outbuf, smb_mid, req->mid);
-	smb_setlen((char *)req->outbuf, talloc_get_size(req->outbuf) - 4);
+
+	smblen = talloc_get_size(req->outbuf) - 4;
+
+	smb_setlen((char *)req->outbuf, smblen);
+
+	if (smblen > 0x1ffff) {
+		/*
+		 * This is a POSIX 14 word large write. Overwrite just the
+		 * size field, the '0xFFSMB' has been set by smb_setlen which
+		 * _smb_setlen_large does not do.
+		 */
+		_smb_setlen_large(((char *)req->outbuf), smblen);
+	}
 
 	cli_calculate_sign_mac(cli, (char *)req->outbuf);
 
@@ -639,6 +652,37 @@ struct async_req *cli_request_send(TALLOC_CTX *mem_ctx,
 }
 
 /**
+ * Calculate the current ofs to wct for requests like write&x
+ * @param[in] req	The smb request we're currently building
+ * @retval how many bytes offset have we accumulated?
+ */
+
+uint16_t cli_wct_ofs(const struct cli_state *cli)
+{
+	size_t buf_size;
+
+	if (cli->chain_accumulator == NULL) {
+		return smb_wct - 4;
+	}
+
+	buf_size = talloc_get_size(cli->chain_accumulator->outbuf);
+
+	if (buf_size == smb_wct) {
+		return smb_wct - 4;
+	}
+
+	/*
+	 * Add alignment for subsequent requests
+	 */
+
+	if ((buf_size % 4) != 0) {
+		buf_size += (4 - (buf_size % 4));
+	}
+
+	return buf_size - 4;
+}
+
+/**
  * Figure out if there is an andx command behind the current one
  * @param[in] buf	The smb buffer to look at
  * @param[in] ofs	The offset to the wct field that is followed by the cmd
diff --git a/source3/smbd/process.c b/source3/smbd/process.c
index b3cd2f2..e4d15d8 100644
--- a/source3/smbd/process.c
+++ b/source3/smbd/process.c
@@ -37,7 +37,8 @@ SIG_ATOMIC_T got_sig_term = 0;
 extern bool global_machine_password_needs_changing;
 extern int max_send;
 
-static void construct_reply_common(const char *inbuf, char *outbuf);
+static void construct_reply_common(struct smb_request *req, const char *inbuf,
+				   char *outbuf);
 
 /* Accessor function for smb_read_error for smbd functions. */
 
@@ -1248,8 +1249,9 @@ static const struct smb_message_struct {
  allocate and initialize a reply packet
 ********************************************************************/
 
-bool create_outbuf(TALLOC_CTX *mem_ctx, const char *inbuf, char **outbuf,
-		   uint8_t num_words, uint32_t num_bytes)
+static bool create_outbuf(TALLOC_CTX *mem_ctx, struct smb_request *req,
+			  const char *inbuf, char **outbuf, uint8_t num_words,
+			  uint32_t num_bytes)
 {
 	/*
          * Protect against integer wrap
@@ -1270,7 +1272,7 @@ bool create_outbuf(TALLOC_CTX *mem_ctx, const char *inbuf, char **outbuf,
 		return false;
 	}
 
-	construct_reply_common(inbuf, *outbuf);
+	construct_reply_common(req, inbuf, *outbuf);
 	srv_set_message(*outbuf, num_words, num_bytes, false);
 	/*
 	 * Zero out the word area, the caller has to take care of the bcc area
@@ -1286,7 +1288,7 @@ bool create_outbuf(TALLOC_CTX *mem_ctx, const char *inbuf, char **outbuf,
 void reply_outbuf(struct smb_request *req, uint8 num_words, uint32 num_bytes)
 {
 	char *outbuf;
-	if (!create_outbuf(req, (char *)req->inbuf, &outbuf, num_words,
+	if (!create_outbuf(req, req, (char *)req->inbuf, &outbuf, num_words,
 			   num_bytes)) {
 		smb_panic("could not allocate output buffer\n");
 	}
@@ -1592,11 +1594,12 @@ void remove_from_common_flags2(uint32 v)
 	common_flags2 &= ~v;
 }
 
-static void construct_reply_common(const char *inbuf, char *outbuf)
+static void construct_reply_common(struct smb_request *req, const char *inbuf,
+				   char *outbuf)
 {
 	srv_set_message(outbuf,0,0,false);
 	
-	SCVAL(outbuf,smb_com,CVAL(inbuf,smb_com));
+	SCVAL(outbuf, smb_com, req->cmd);
 	SIVAL(outbuf,smb_rcls,0);
 	SCVAL(outbuf,smb_flg, FLAG_REPLY | (CVAL(inbuf,smb_flg) & FLAG_CASELESS_PATHNAMES)); 
 	SSVAL(outbuf,smb_flg2,
@@ -1612,7 +1615,7 @@ static void construct_reply_common(const char *inbuf, char *outbuf)
 
 void construct_reply_common_req(struct smb_request *req, char *outbuf)
 {
-	construct_reply_common((char *)req->inbuf, outbuf);
+	construct_reply_common(req, (char *)req->inbuf, outbuf);
 }
 
 /****************************************************************************


-- 
Samba Shared Repository


More information about the samba-cvs mailing list